pub struct Dims { /* private fields */ }Expand description
A horizontal and vertical rectangular dimension with no specified location.
Implementations§
Source§impl Dims
impl Dims
Sourcepub fn dim(&self, dir: Dir) -> i64
pub fn dim(&self, dir: Dir) -> i64
Returns the dimension in the specified direction.
§Example
let dims = Dims::new(100, 200);
assert_eq!(dims.dim(Dir::Vert), 200);
assert_eq!(dims.dim(Dir::Horiz), 100);Sourcepub fn longer_dir(&self) -> Dir
pub fn longer_dir(&self) -> Dir
Returns the direction of the longer dimension.
If the width and height are equal, returns Dir::Horiz.
§Example
let dims = Dims::new(100, 200);
assert_eq!(dims.longer_dir(), Dir::Vert);
let dims = Dims::new(200, 100);
assert_eq!(dims.longer_dir(), Dir::Horiz);
let dims = Dims::new(100, 100);
assert_eq!(dims.longer_dir(), Dir::Horiz);Sourcepub fn longer_dir_strict(&self) -> Option<Dir>
pub fn longer_dir_strict(&self) -> Option<Dir>
Returns the direction of the longer dimension.
If the width and height are equal, returns None.
Otherwise, returns a Some variant containing the longer direction.
Sourcepub fn transpose(self) -> Dims
pub fn transpose(self) -> Dims
Returns a new Dims object with the horizontal and vertical dimensions flipped.
Sourcepub fn w(&self) -> i64
pub fn w(&self) -> i64
Returns the width (i.e. the horizontal dimension).
A shorthand for Dims::width.
Sourcepub fn h(&self) -> i64
pub fn h(&self) -> i64
Returns the height (i.e. the vertical dimension).
A shorthand for Dims::height.
Sourcepub fn into_rect(self) -> Rect
pub fn into_rect(self) -> Rect
Converts this dimension object into a Rect.
See Rect::from_dims for more information.
Sourcepub fn into_point(self) -> Point
pub fn into_point(self) -> Point
Converts this dimension object into a Point with coordinates (self.w(), self.h()).
Trait Implementations§
Source§impl AddAssign<Dims> for Point
impl AddAssign<Dims> for Point
Source§fn add_assign(&mut self, rhs: Dims)
fn add_assign(&mut self, rhs: Dims)
+= operation. Read moreSource§impl AddAssign for Dims
impl AddAssign for Dims
Source§fn add_assign(&mut self, rhs: Dims)
fn add_assign(&mut self, rhs: Dims)
+= operation. Read moreSource§impl<'de> Deserialize<'de> for Dims
impl<'de> Deserialize<'de> for Dims
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Dims, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Dims, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl MulAssign<i64> for Dims
impl MulAssign<i64> for Dims
Source§fn mul_assign(&mut self, rhs: i64)
fn mul_assign(&mut self, rhs: i64)
*= operation. Read moreSource§impl Ord for Dims
impl Ord for Dims
Source§impl PartialOrd for Dims
impl PartialOrd for Dims
Source§impl Serialize for Dims
impl Serialize for Dims
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl SubAssign for Dims
impl SubAssign for Dims
Source§fn sub_assign(&mut self, rhs: Dims)
fn sub_assign(&mut self, rhs: Dims)
-= operation. Read moreimpl Copy for Dims
impl Eq for Dims
impl StructuralPartialEq for Dims
Auto Trait Implementations§
impl Freeze for Dims
impl RefUnwindSafe for Dims
impl Send for Dims
impl Sync for Dims
impl Unpin for Dims
impl UnwindSafe for Dims
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].