Struct gridly::location::Ordered

source ·
pub struct Ordered<L: LocationLike, Major: Component> {
    pub location: L,
    /* private fields */
}
Expand description

Rules for ordering a location. This struct wraps a LocationLike and supplies an Ord and PartialOrd implementation. The Major type parameter indicates which ordering is used; for instance, Ordering<Row> provides row-major ordering, where Locations are sorted first by row, then by column.

Fields§

§location: L

Implementations§

source§

impl<L: LocationLike, M: Component> Ordered<L, M>

source

pub fn new(location: L) -> Self

Trait Implementations§

source§

impl<L: LocationLike, M: Component> AsMut<L> for Ordered<L, M>

source§

fn as_mut(&mut self) -> &mut L

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<L: LocationLike, M: Component> AsRef<L> for Ordered<L, M>

source§

fn as_ref(&self) -> &L

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<L: Clone + LocationLike, Major: Clone + Component> Clone for Ordered<L, Major>

source§

fn clone(&self) -> Ordered<L, Major>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<L: Debug + LocationLike, Major: Debug + Component> Debug for Ordered<L, Major>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<L: Default + LocationLike, Major: Default + Component> Default for Ordered<L, Major>

source§

fn default() -> Ordered<L, Major>

Returns the “default value” for a type. Read more
source§

impl<L: LocationLike, M: Component> Deref for Ordered<L, M>

§

type Target = L

The resulting type after dereferencing.
source§

fn deref(&self) -> &L

Dereferences the value.
source§

impl<L: LocationLike, M: Component> DerefMut for Ordered<L, M>

source§

fn deref_mut(&mut self) -> &mut L

Mutably dereferences the value.
source§

impl<L: LocationLike, M: Component> From<L> for Ordered<L, M>

source§

fn from(location: L) -> Self

Converts to this type from the input type.
source§

impl<L: Hash + LocationLike, Major: Hash + Component> Hash for Ordered<L, Major>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<L: LocationLike, M: Component> LocationLike for Ordered<L, M>

source§

fn row(&self) -> Row

Get the row of this location.
source§

fn column(&self) -> Column

Get the column of this location.
source§

fn as_location(&self) -> Location

Convert this object into a Location struct.
source§

fn get_component<T: Component>(&self) -> T

Get either the row or column of a location. This method is useful in code that is generic over the Row or Column.
source§

fn above(&self, distance: impl Into<Rows>) -> Location

Return the location that is distance rows above this one Read more
source§

fn below(&self, distance: impl Into<Rows>) -> Location

Return the location that is distance rows below this one Read more
source§

fn left(&self, distance: impl Into<Columns>) -> Location

Return the location that is distance columns to the left of this one Read more
source§

fn right(&self, distance: impl Into<Columns>) -> Location

Return the location that is distance columns to the right of this one Read more
source§

fn add(&self, distance: impl VectorLike) -> Location

Return the location that is distance away from this one.
source§

fn relative(&self, direction: Direction, distance: isize) -> Location

Return the location that is distance away in the given direction Read more
source§

fn step(&self, direction: Direction) -> Location

Return the location that is 1 away in the given direction Read more
source§

fn transpose(&self) -> Location

Swap the row and colimn of this Location Read more
source§

fn order_by<Major: Component>(self) -> Ordered<Self, Major>

Generically get strictly ordered version of this Location. The Major is the ordering; for example, order_by::<Row> will create a row-ordered Location. See row_ordered or column_ordered for an example.
source§

fn row_ordered(self) -> RowOrdered<Self>

Get a strictly row-ordered version of this Location; that is, a location which is ordered by comparing the row, then the column. Read more
source§

fn column_ordered(self) -> ColumnOrdered<Self>

Get a strictly row-ordered version of this Location; that is, a location which is ordered by comparing the row, then the column. Read more
source§

fn span_over<C: VecComponent>( self, distance: C ) -> LocationRange<<C::Point as Component>::Converse>

Create a range, starting at this location, with the given length Read more
source§

fn range_to<C: Component>(self, end: C) -> LocationRange<C::Converse>

Create a range, starting at this component, ending at the given component Read more
source§

impl<L: LocationLike, M: Component> Ord for Ordered<L, M>

source§

fn cmp(&self, rhs: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<L: LocationLike, M: Component, R: LocationLike> PartialEq<R> for Ordered<L, M>

source§

fn eq(&self, rhs: &R) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<L: LocationLike, M: Component> PartialOrd for Ordered<L, M>

source§

fn partial_cmp(&self, rhs: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
source§

fn lt(&self, rhs: &Self) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
source§

fn le(&self, rhs: &Self) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
source§

fn gt(&self, rhs: &Self) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
source§

fn ge(&self, rhs: &Self) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<L: Copy + LocationLike, Major: Copy + Component> Copy for Ordered<L, Major>

source§

impl<L: LocationLike, M: Component> Eq for Ordered<L, M>

Auto Trait Implementations§

§

impl<L, Major> RefUnwindSafe for Ordered<L, Major>
where L: RefUnwindSafe, Major: RefUnwindSafe,

§

impl<L, Major> Send for Ordered<L, Major>
where L: Send, Major: Send,

§

impl<L, Major> Sync for Ordered<L, Major>
where L: Sync, Major: Sync,

§

impl<L, Major> Unpin for Ordered<L, Major>
where L: Unpin, Major: Unpin,

§

impl<L, Major> UnwindSafe for Ordered<L, Major>
where L: UnwindSafe, Major: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<!> for T

source§

fn from(t: !) -> T

Converts to this type from the input type.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.