pub enum Symmetry {
    C1,
    C2,
    C4,
    D2Row,
    D2Col,
    D2Diag,
    D2Antidiag,
    D4Ortho,
    D4Diag,
    D8,
}
Expand description

Symmetries of the pattern.

For each symmetry, its symmetry group is a subgroup of the dihedral group D8. 10 different symmetries correspond to 10 subgroups of D8.

The notations are stolen from Oscar Cunningham’s Logic Life Search. Please see the Life Wiki for details.

Some of the symmetries are only valid when the world is square, and some are only valid when the world has no diagonal width.

Variants§

§

C1

C1.

No symmetry at all.

§

C2

C2.

Symmetry under 180° rotation.

§

C4

C4.

Symmetry under 90° rotation.

Requires the world to be square and have no diagonal width.

§

D2Row

D2-.

Symmetry under reflection across the middle row.

Requires the world to have no diagonal width.

§

D2Col

D2|.

Symmetry under reflection across the middle column.

Requires the world to have no diagonal width.

§

D2Diag

D2\.

Symmetry under reflection across the diagonal.

Requires the world to be square.

§

D2Antidiag

D2/.

Symmetry under reflection across the antidiagonal.

Requires the world to be square.

§

D4Ortho

D4+.

Symmetry under reflections across the middle row and the middle column.

Requires the world to have no diagonal width.

§

D4Diag

D4X.

Symmetry under reflections across the diagonal and the antidiagonal.

Requires the world to be square.

§

D8

D8.

Symmetry under all 8 transformations.

Requires the world to be square and have no diagonal width.

Implementations§

source§

impl Symmetry

source

pub const ALL: [Self; 10] = _

source

pub const fn is_subgroup_of(self, other: Self) -> bool

Whether the symmetry group of self is a subgroup of that of other, i.e., all patterns with symmetry other also have symmetry self.

For example, the symmetry group of Symmetry::C1 is a subgroup of that of all other symmetries.

source

pub const fn require_square_world(self) -> bool

Whether this symmetry requires the world to be square.

Returns true for C4, D2\, D2/, D4X and D8.

source

pub const fn require_no_diagonal_width(self) -> bool

Whether this transformation requires the world to have no diagonal width.

Returns true for C4, D2-, D2|, D4+ and D8.

source

pub fn members(self) -> Vec<Transform>

Transformations contained in the symmetry group.

source

pub fn cosets(self) -> Vec<Transform>

A list of coset representatives, seeing the symmetry group as a subgroup of D8.

The first element in the result is always Transform::Id.

source

pub const fn generated_with(self, transform: Transform) -> Self

The symmetry group “generated by” the given symmetry and the transformation. i.e., the smallest symmetry group which is larger than the given symmetry group and contains that transformation.

source

pub fn generated_by(transforms: impl IntoIterator<Item = Transform>) -> Self

The symmetry group generated by the given transformations, i.e., the smallest symmetry group containing all these transformations.

Trait Implementations§

source§

impl Clone for Symmetry

source§

fn clone(&self) -> Symmetry

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 Debug for Symmetry

source§

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

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

impl Default for Symmetry

source§

fn default() -> Symmetry

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

impl<'de> Deserialize<'de> for Symmetry

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 Display for Symmetry

source§

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

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

impl FromStr for Symmetry

§

type Err = String

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for Symmetry

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 PartialEq for Symmetry

source§

fn eq(&self, other: &Symmetry) -> 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 PartialOrd for Symmetry

source§

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

We say that symmetry a is smaller than symmetry b, when the symmetry group of a is a subgroup of that of b, i.e., all patterns with symmetry b also have symmetry a.

For example, Symmetry::C1 is smaller than all other symmetries.

1.0.0 · source§

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

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

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

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

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

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

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

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

impl Serialize for Symmetry

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 Copy for Symmetry

source§

impl Eq for Symmetry

source§

impl StructuralEq for Symmetry

source§

impl StructuralPartialEq for Symmetry

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere 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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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<V, T> VZip<V> for Twhere V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

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