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 PartialEq for Dims
impl PartialEq for Dims
source§impl PartialOrd for Dims
impl PartialOrd for Dims
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§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 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
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<T, U> CustomHardwareType<Flipped<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
impl<T, U> CustomHardwareType<Flipped<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
source§fn from_layout_type(other: &Flipped<T>) -> U
fn from_layout_type(other: &Flipped<T>) -> U
source§impl<T, U> CustomHardwareType<InOut<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
impl<T, U> CustomHardwareType<InOut<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
source§fn from_layout_type(other: &InOut<T>) -> U
fn from_layout_type(other: &InOut<T>) -> U
source§impl<T, U> CustomHardwareType<Input<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
impl<T, U> CustomHardwareType<Input<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
source§fn from_layout_type(other: &Input<T>) -> U
fn from_layout_type(other: &Input<T>) -> U
source§impl<T, U> CustomHardwareType<Output<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
impl<T, U> CustomHardwareType<Output<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
source§fn from_layout_type(other: &Output<T>) -> U
fn from_layout_type(other: &Output<T>) -> U
§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>
. Box<dyn Any>
can
then be further downcast
into Box<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>
. Rc<Any>
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> DowncastSync for T
impl<T> DowncastSync for T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§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<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<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>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request