pub struct Size {
pub width: u32,
pub height: u32,
}Expand description
Represents a size (width and height) of a rectangle.
Fields§
§width: u32§height: u32Implementations§
Source§impl Size
impl Size
Sourcepub fn new(width: u32, height: u32) -> Size
pub fn new(width: u32, height: u32) -> Size
Creates a new Size with the specified width and height.
Sourcepub fn reduce_by(&self, value: u32) -> Size
pub fn reduce_by(&self, value: u32) -> Size
Reduces the size with a specified value. If that value is greater than the width or height, that parameter will be clamped to 0.
§Example
use appcui::graphics::Size;
let size = Size::new(10, 10);
// Reduce the size by 3
let reduced_size = size.reduce_by(3);
assert_eq!(reduced_size.width, 7);
assert_eq!(reduced_size.height, 7);
// Reduce the size by 100 (since 100 is greater than
// the width and height, the result will be 0)
let reduced_size_zero = size.reduce_by(100);
assert_eq!(reduced_size_zero.width, 0);
assert_eq!(reduced_size_zero.height, 0);Trait Implementations§
impl Copy for Size
impl Eq for Size
impl StructuralPartialEq for Size
Auto Trait Implementations§
impl Freeze for Size
impl RefUnwindSafe for Size
impl Send for Size
impl Sync for Size
impl Unpin for Size
impl UnsafeUnpin for Size
impl UnwindSafe for Size
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.