Skip to main content

Position

Struct Position 

Source
pub struct Position<V> { /* private fields */ }
Expand description

A position in the board (eff., a coordinate pair).

Implementations§

Source§

impl<V> Position<V>

Source

pub fn row(&self) -> &V

The row of the position.

Source

pub fn column(&self) -> &V

The column of the position.

Source§

impl<V> Position<V>
where V: BoardValue,

Source

pub fn as_index(&self, dim: &Dimensions<V>) -> Option<usize>

The position encoded as an index into an board with the provided dimensions.

Source§

impl<V> Position<V>
where Self: CheckedAdd<Output = Self> + CheckedSub<Output = Self>, V: BoardValue,

Source

pub fn shift(&self, dir: Direction, by: V) -> Option<Self>

Get the position by units away from this position in the provided direction dir, or None if the position would be out of bounds.

Trait Implementations§

Source§

impl<V> Add for Position<V>
where V: BoardValue,

Source§

type Output = Position<V>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<V> AddAssign for Position<V>
where V: BoardValue,

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl<V> CheckedAdd for Position<V>
where V: BoardValue,

Source§

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

Adds two numbers, checking for overflow. If overflow happens, None is returned.
Source§

impl<V> CheckedSub for Position<V>
where V: BoardValue,

Source§

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

Subtracts two numbers, checking for underflow. If underflow happens, None is returned.
Source§

impl<V: Clone> Clone for Position<V>

Source§

fn clone(&self) -> Position<V>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<V: Debug> Debug for Position<V>

Source§

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

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

impl<'de, V> Deserialize<'de> for Position<V>
where V: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<V> From<(V, V)> for Position<V>

Source§

fn from((row, column): (V, V)) -> Self

Converts to this type from the input type.
Source§

impl<V: Hash> Hash for Position<V>

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<V> Serialize for Position<V>
where V: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<V> Sub for Position<V>
where V: BoardValue,

Source§

type Output = Position<V>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<V: Copy> Copy for Position<V>

Auto Trait Implementations§

§

impl<V> Freeze for Position<V>
where V: Freeze,

§

impl<V> RefUnwindSafe for Position<V>
where V: RefUnwindSafe,

§

impl<V> Send for Position<V>
where V: Send,

§

impl<V> Sync for Position<V>
where V: Sync,

§

impl<V> Unpin for Position<V>
where V: Unpin,

§

impl<V> UnsafeUnpin for Position<V>
where V: UnsafeUnpin,

§

impl<V> UnwindSafe for Position<V>
where V: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,