pub enum Orientation {
Horizontal,
Vertical,
}
Expand description
Describes a vertical or horizontal orientation for a view.
Variants§
Implementations§
Source§impl Orientation
impl Orientation
Sourcepub const fn pair() -> XY<Orientation>
pub const fn pair() -> XY<Orientation>
Returns a XY(Horizontal, Vertical)
.
Sourcepub fn get<T: Clone>(self, v: &XY<T>) -> T
pub fn get<T: Clone>(self, v: &XY<T>) -> T
Returns the component of v
corresponding to this orientation.
(Horizontal
will return the x value,
and Vertical
will return the y value.)
Sourcepub fn get_mut<T>(self, v: &mut XY<T>) -> &mut T
pub fn get_mut<T>(self, v: &mut XY<T>) -> &mut T
Returns a mutable reference to the component of the given vector corresponding to this orientation.
§Examples
let o = Orientation::Horizontal;
let mut xy = XY::new(1, 2);
*o.get_mut(&mut xy) = 42;
assert_eq!(xy, XY::new(42, 2));
Sourcepub fn get_ref<T>(self, v: &mut XY<T>) -> &mut T
👎Deprecated
pub fn get_ref<T>(self, v: &mut XY<T>) -> &mut T
Same as Self::get_mut()
.
Sourcepub fn stack<T: Iterator<Item = Vec2>>(self, iter: T) -> Vec2
pub fn stack<T: Iterator<Item = Vec2>>(self, iter: T) -> Vec2
Takes an iterator on sizes, and stack them in the current orientation, returning the size of the required bounding box.
- For an horizontal view, returns
(Sum(x), Max(y))
. - For a vertical view, returns
(Max(x), Sum(y))
.
Sourcepub const fn make_vec(self, main_axis: usize, second_axis: usize) -> Vec2
pub const fn make_vec(self, main_axis: usize, second_axis: usize) -> Vec2
Creates a new Vec2
with main_axis
in self
’s axis, and
second_axis
for the other axis.
§Examples
let o = Orientation::Horizontal;
let vec = o.make_vec(1, 2);
assert_eq!(vec, Vec2::new(1, 2));
let o = Orientation::Vertical;
let vec = o.make_vec(1, 2);
assert_eq!(vec, Vec2::new(2, 1));
Trait Implementations§
Source§impl Clone for Orientation
impl Clone for Orientation
Source§fn clone(&self) -> Orientation
fn clone(&self) -> Orientation
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 Orientation
impl Debug for Orientation
Source§impl FromStr for Orientation
impl FromStr for Orientation
Source§impl Hash for Orientation
impl Hash for Orientation
Source§impl PartialEq for Orientation
impl PartialEq for Orientation
Source§impl Resolvable for Orientation
impl Resolvable for Orientation
impl Copy for Orientation
impl Eq for Orientation
impl StructuralPartialEq for Orientation
Auto Trait Implementations§
impl Freeze for Orientation
impl RefUnwindSafe for Orientation
impl Send for Orientation
impl Sync for Orientation
impl Unpin for Orientation
impl UnwindSafe for Orientation
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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
Compare self to
key
and return true
if they are equal.