Use new with_* naming scheme

All builder-like functions are now named with_*. There is also now a way
to set each property imperatively with only a mutable reference.

The only widgets I haven't yet converted to this style are the Join*
widgets; they're a bit harder to figure out an appropriate API for.
This commit is contained in:
Joscha 2023-02-20 15:53:49 +01:00
parent cb483431cc
commit 607c11fea4
11 changed files with 125 additions and 90 deletions

View file

@ -4,7 +4,7 @@ use crate::{AsyncWidget, Frame, Size, Widget};
#[derive(Debug, Default, Clone, Copy)]
pub struct Empty {
size: Size,
pub size: Size,
}
impl Empty {
@ -12,17 +12,17 @@ impl Empty {
Self { size: Size::ZERO }
}
pub fn width(mut self, width: u16) -> Self {
pub fn with_width(mut self, width: u16) -> Self {
self.size.width = width;
self
}
pub fn height(mut self, height: u16) -> Self {
pub fn with_height(mut self, height: u16) -> Self {
self.size.height = height;
self
}
pub fn size(mut self, size: Size) -> Self {
pub fn with_size(mut self, size: Size) -> Self {
self.size = size;
self
}