[−][src]Struct ingrid::Size
A two-dimensional size
This structure defines a basic two-dimensional size to specify the dimension
of grids. It enables copy semantics to avoid handling ownership and
references throughout your code for no significant performance. Also, in
practice, you use the size!
macro helper to instantiate sizes; this is to
be consistent with the use of coordinates.
Examples
// Create a size to specify the dimension of a grid. let mut size1 = size!(24, 42); // Copy the size into another variable. let size2 = size1; // The first variable is still accessible. size1.width = 42; size1.height = 0; // Additionally, you could also type the following. let size3 = Size::zero();
Fields
width: usize
The width of the size.
height: usize
The height of the size.
Methods
impl Size
[src]
pub fn new(width: usize, height: usize) -> Size
[src]
Construct a new size.
This function constructs a new coordinate from given width and height values.
Examples
let size = Size::new(24, 42); assert_eq!(size.width, 24); assert_eq!(size.height, 42);
pub fn zero() -> Size
[src]
Construct a zero size.
This function constructs a 'zero' size which is a coordinate with both
width
and height
values set at 0
.
Examples
let size = Size::zero(); assert_eq!(size.width, 0); assert_eq!(size.height, 0);
Trait Implementations
impl Clone for Size
[src]
impl Copy for Size
[src]
impl Debug for Size
[src]
impl Eq for Size
[src]
impl PartialEq<Size> for Size
[src]
impl StructuralEq for Size
[src]
impl StructuralPartialEq for Size
[src]
Auto Trait Implementations
impl RefUnwindSafe for Size
impl Send for Size
impl Sync for Size
impl Unpin for Size
impl UnwindSafe for Size
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,