Pots

Struct Pots 

Source
struct Pots {
    state: Vec<u8>,
    prev_state: Vec<u8>,
    pos: i64,
}

Fields§

§state: Vec<u8>

Vector representing the pots. 1 means there is a plant in the pot, 0 means there isn’t.

§prev_state: Vec<u8>

A copy of the vector state before Self::step was called.

§pos: i64

The id of the pot at the beginning of the bit vector state.

Implementations§

Source§

impl Pots

Source

fn from(initial_state: &[u8]) -> Self

Parses the initial state into a bit vector

Source

fn step(&mut self, rules: &[u8; 32])

Applies the given rules to the pots and updates Self::state. A copy of the state before this method was called is left in Self::prev_state.

Source

fn sum(&self) -> i64

Returns the sum of the numbers of all pots containing plants

Auto Trait Implementations§

§

impl Freeze for Pots

§

impl RefUnwindSafe for Pots

§

impl Send for Pots

§

impl Sync for Pots

§

impl Unpin for Pots

§

impl UnwindSafe for Pots

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

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.