FaceMap

Struct FaceMap 

Source
pub struct FaceMap<V> {
    pub nx: V,
    pub ny: V,
    pub nz: V,
    pub px: V,
    pub py: V,
    pub pz: V,
}
Expand description

Container for values keyed by Face6s. Always holds exactly six elements.

Fields§

§nx: V

The value whose key is Face6::NX.

§ny: V

The value whose key is Face6::NY.

§nz: V

The value whose key is Face6::NZ.

§px: V

The value whose key is Face6::PX.

§py: V

The value whose key is Face6::PY.

§pz: V

The value whose key is Face6::PZ.

Implementations§

Source§

impl<V> FaceMap<V>

Source

pub fn from_fn(f: impl FnMut(Face6) -> V) -> Self

Constructs a FaceMap by using the provided function to compute a value for each Face6 enum variant.

Source

pub fn negatives<U>(self) -> Vector3D<V, U>
where V: Copy,

Returns a vector containing the values for each negative face.

Source

pub fn positives<U>(self) -> Vector3D<V, U>
where V: Copy,

Returns a vector containing the values for each positive face.

Source

pub fn iter(&self) -> impl Iterator<Item = (Face6, &V)>

Iterate over the map’s key-value pairs by reference, in the same order as Face6::ALL.

Source

pub fn iter_mut(&mut self) -> impl Iterator<Item = (Face6, &mut V)>

Iterate over the map’s key-value pairs by mutable reference, in the same order as Face6::ALL.

Source

pub fn values(&self) -> impl Iterator<Item = &V>

Iterate over the map values by reference, in the same order as Face6::ALL.

Source

pub fn into_values(self) -> [V; 6]

Convert to an array, whose elements are arranged in the same order as Face6::ALL.

Source

pub fn into_values_iter(self) -> impl Iterator<Item = V>

Convert to an iterator, whose items are arranged in the same order as Face6::ALL.

Source

pub fn map<U>(self, f: impl FnMut(Face6, V) -> U) -> FaceMap<U>

Transform values.

Source

pub fn zip<U, R>( self, other: FaceMap<U>, f: impl FnMut(Face6, V, U) -> R, ) -> FaceMap<R>

Combine two FaceMaps using a function applied to each pair of corresponding values.

Source

pub fn with(self, face: Face6, value: V) -> Self

Returns this map with one entry’s value replaced.

This may be used for constructing a map with only one interesting entry:

use all_is_cubes::math::{Face6, FaceMap};

assert_eq!(
    FaceMap::default().with(Face6::PY, 10),
    {
        let mut m = FaceMap::default();
        m[Face6::PY] = 10;
        m
    },
);
Source

pub fn rotate(self, rotation: GridRotation) -> Self

Shuffle the values in this map according to the given rotation.

Source§

impl<V: Clone> FaceMap<V>

Source

pub fn splat(value: V) -> Self

Constructs a FaceMap containing clones of the provided value.

Source§

impl<V: Copy> FaceMap<V>

Source

pub const fn splat_copy(value: V) -> Self

Constructs a FaceMap containing copies of the provided value.

This is practically identical to FaceMap::splat() except that it is a const fn. It may be removed from future major versions once Rust supports const trait function calls.

Trait Implementations§

Source§

impl<V: Add> Add for FaceMap<V>

Source§

fn add(self, other: FaceMap<V>) -> FaceMap<V::Output>

Apply the operator pairwise to the values for all six faces.

Source§

type Output = FaceMap<<V as Add>::Output>

The resulting type after applying the + operator.
Source§

impl<V: BitAnd> BitAnd for FaceMap<V>

Source§

fn bitand(self, other: FaceMap<V>) -> FaceMap<V::Output>

Apply the operator pairwise to the values for all six faces.

Source§

type Output = FaceMap<<V as BitAnd>::Output>

The resulting type after applying the & operator.
Source§

impl<V: BitOr> BitOr for FaceMap<V>

Source§

fn bitor(self, other: FaceMap<V>) -> FaceMap<V::Output>

Apply the operator pairwise to the values for all six faces.

Source§

type Output = FaceMap<<V as BitOr>::Output>

The resulting type after applying the | operator.
Source§

impl<V: BitXor> BitXor for FaceMap<V>

Source§

fn bitxor(self, other: FaceMap<V>) -> FaceMap<V::Output>

Apply the operator pairwise to the values for all six faces.

Source§

type Output = FaceMap<<V as BitXor>::Output>

The resulting type after applying the ^ operator.
Source§

impl<V: Clone> Clone for FaceMap<V>

Source§

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

Returns a duplicate 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<V> Debug for FaceMap<V>
where V: Debug + PartialEq,

Source§

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

In addition to the usual formatting behaviors, FaceMap will detect whether elements are equal and avoid redundant printing.

Source§

impl<V: Default> Default for FaceMap<V>

Source§

fn default() -> FaceMap<V>

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

impl<V: Div> Div for FaceMap<V>

Source§

fn div(self, other: FaceMap<V>) -> FaceMap<V::Output>

Apply the operator pairwise to the values for all six faces.

Source§

type Output = FaceMap<<V as Div>::Output>

The resulting type after applying the / operator.
Source§

impl<V> Exhaust for FaceMap<V>
where V: Exhaust,

Source§

type Iter = ExhaustFaceMapIter<V>

Iterator type returned by Self::exhaust_factories(). See the trait documentation for what properties this iterator should have. Read more
Source§

type Factory = ExhaustFaceMapFactory<V>

Data which can be used to construct Self. Read more
Source§

fn exhaust_factories() -> Self::Iter

Returns an iterator over factories for all values of this type. Read more
Source§

fn from_factory(factory: Self::Factory) -> Self

Construct a concrete value of this type from a Self::Factory value produced by its Self::Iter. Read more
Source§

fn exhaust() -> Iter<Self>

Returns an iterator over all values of this type. Read more
Source§

impl<V: Hash> Hash for FaceMap<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> Index<Face6> for FaceMap<V>

Source§

type Output = V

The returned type after indexing.
Source§

fn index(&self, face: Face6) -> &V

Performs the indexing (container[index]) operation. Read more
Source§

impl<V> IndexMut<Face6> for FaceMap<V>

Source§

fn index_mut(&mut self, face: Face6) -> &mut V

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<V: Mul> Mul for FaceMap<V>

Source§

fn mul(self, other: FaceMap<V>) -> FaceMap<V::Output>

Apply the operator pairwise to the values for all six faces.

Source§

type Output = FaceMap<<V as Mul>::Output>

The resulting type after applying the * operator.
Source§

impl<V: PartialEq> PartialEq for FaceMap<V>

Source§

fn eq(&self, other: &FaceMap<V>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<V: Rem> Rem for FaceMap<V>

Source§

fn rem(self, other: FaceMap<V>) -> FaceMap<V::Output>

Apply the operator pairwise to the values for all six faces.

Source§

type Output = FaceMap<<V as Rem>::Output>

The resulting type after applying the % operator.
Source§

impl<V: Sub> Sub for FaceMap<V>

Source§

fn sub(self, other: FaceMap<V>) -> FaceMap<V::Output>

Apply the operator pairwise to the values for all six faces.

Source§

type Output = FaceMap<<V as Sub>::Output>

The resulting type after applying the - operator.
Source§

impl<V: Copy> Copy for FaceMap<V>

Source§

impl<V: Eq> Eq for FaceMap<V>

Source§

impl<V> StructuralPartialEq for FaceMap<V>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<V> UnwindSafe for FaceMap<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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
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> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
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> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,