pub struct Dimensions {
pub rows: usize,
pub columns: usize,
}Expand description
Non-zero rectangle dimensions
let d = Dimensions::from ((3, 2));
assert_eq!(d.rows, 3);
assert_eq!(d.columns, 2);
assert_eq!(d.area(), 6);
assert!( d.contains ((1, 1).into()));
assert!(!d.contains ((4, 1).into()));
assert!(!d.contains ((1, 3).into()));
let rect = Rectangle::from (d);
assert_eq!(rect.min(), (0, 0).into());
assert_eq!(rect.max(), (2, 1).into());Fields§
§rows: usize§columns: usizeImplementations§
Source§impl Dimensions
impl Dimensions
Sourcepub fn contains(&self, _: Coordinate) -> bool
pub fn contains(&self, _: Coordinate) -> bool
Return true if the coordinate fits within self’s columns and rows, false
otherwise
pub fn contains_rc(&self, row: usize, column: usize) -> bool
pub fn row(&self, row: usize) -> Option<Rectangle>
pub fn column(&self, column: usize) -> Option<Rectangle>
Trait Implementations§
Source§impl Add<Dimensions> for Coordinate
impl Add<Dimensions> for Coordinate
Source§type Output = Coordinate
type Output = Coordinate
The resulting type after applying the
+ operator.Source§fn add(self, rhs: Dimensions) -> Coordinate
fn add(self, rhs: Dimensions) -> Coordinate
Performs the
+ operation. Read moreSource§impl Add for Dimensions
impl Add for Dimensions
Source§type Output = Dimensions
type Output = Dimensions
The resulting type after applying the
+ operator.Source§fn add(self, rhs: Dimensions) -> Dimensions
fn add(self, rhs: Dimensions) -> Dimensions
Performs the
+ operation. Read moreSource§impl Clone for Dimensions
impl Clone for Dimensions
Source§fn clone(&self) -> Dimensions
fn clone(&self) -> Dimensions
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Dimensions
impl Debug for Dimensions
Source§impl Default for Dimensions
impl Default for Dimensions
Source§fn default() -> Dimensions
fn default() -> Dimensions
Returns the “default value” for a type. Read more
Source§impl From<Dimensions> for [usize; 2]
impl From<Dimensions> for [usize; 2]
Source§fn from(_: Dimensions) -> Self
fn from(_: Dimensions) -> Self
Converts to this type from the input type.
Source§impl From<Dimensions> for (usize, usize)
impl From<Dimensions> for (usize, usize)
Source§fn from(_: Dimensions) -> Self
fn from(_: Dimensions) -> Self
Converts to this type from the input type.
Source§impl From<Dimensions> for Rectangle
impl From<Dimensions> for Rectangle
Source§fn from(dimensions: Dimensions) -> Self
fn from(dimensions: Dimensions) -> Self
Converts to this type from the input type.
Source§impl PartialEq for Dimensions
impl PartialEq for Dimensions
Source§impl Sub<Dimensions> for Coordinate
impl Sub<Dimensions> for Coordinate
Source§type Output = Coordinate
type Output = Coordinate
The resulting type after applying the
- operator.Source§fn sub(self, rhs: Dimensions) -> Coordinate
fn sub(self, rhs: Dimensions) -> Coordinate
Performs the
- operation. Read moreSource§impl Sub for Dimensions
impl Sub for Dimensions
Source§type Output = Dimensions
type Output = Dimensions
The resulting type after applying the
- operator.Source§fn sub(self, rhs: Dimensions) -> Dimensions
fn sub(self, rhs: Dimensions) -> Dimensions
Performs the
- operation. Read moreimpl Copy for Dimensions
impl Eq for Dimensions
impl StructuralPartialEq for Dimensions
Auto Trait Implementations§
impl Freeze for Dimensions
impl RefUnwindSafe for Dimensions
impl Send for Dimensions
impl Sync for Dimensions
impl Unpin for Dimensions
impl UnwindSafe for Dimensions
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