Struct all_is_cubes::math::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) -> FaceMap<V>

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) -> FaceMap<V>

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) -> FaceMap<V>

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

source§

impl<V> FaceMap<V>
where V: Clone,

source

pub fn repeat(value: V) -> FaceMap<V>

Constructs a FaceMap containing clones of the provided value.

source§

impl<V> FaceMap<V>
where V: Copy,

source

pub const fn repeat_copy(value: V) -> FaceMap<V>

Constructs a FaceMap containing copies of the provided value.

This is practically identical to FaceMap::repeat() 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 for FaceMap<V>
where V: Add,

source§

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

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

§

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

The resulting type after applying the + operator.
source§

impl<'arbitrary, V> Arbitrary<'arbitrary> for FaceMap<V>
where V: Arbitrary<'arbitrary>,

source§

fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<FaceMap<V>, Error>

Generate an arbitrary value of Self from the given unstructured data. Read more
source§

fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<FaceMap<V>, Error>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
source§

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

source§

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

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

§

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

The resulting type after applying the & operator.
source§

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

source§

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

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

§

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

The resulting type after applying the | operator.
source§

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

source§

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

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

§

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

The resulting type after applying the ^ operator.
source§

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

source§

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

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

source§

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

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

source§

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

source§

fn default() -> FaceMap<V>

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

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

source§

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

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

§

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

The resulting type after applying the / operator.
source§

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

§

type Iter = ExhaustFaceMap<V>

Type of iterator returned by Self::exhaust(). Read more
source§

fn exhaust() -> <FaceMap<V> as Exhaust>::Iter

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

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

source§

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

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>

§

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 for FaceMap<V>
where V: Mul,

source§

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

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

§

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

The resulting type after applying the * operator.
source§

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

source§

fn eq(&self, other: &FaceMap<V>) -> 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<V> Rem for FaceMap<V>
where V: Rem,

source§

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

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

§

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

The resulting type after applying the % operator.
source§

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

source§

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

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

§

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

The resulting type after applying the - operator.
source§

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

source§

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

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

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> Downcast for T
where T: Any,

source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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.
source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

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

§

type EqTo = T

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,

§

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

§

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