[][src]Struct gear_combos::Gear

pub struct Gear { /* fields omitted */ }

Represents a gear that can cycle through states. It keeps track of the states available and which state it is currently in.

Methods

impl Gear[src]

pub fn new(size: usize) -> Gear[src]

Returns a new gear with an initial state of 0. Populates states with a vector starting from 0, until the end of 'size' - 1.

Example

use gear_combos::Gear;
let gear = Gear::new(2);

assert_eq!(&vec![0,1], gear.states());
assert_eq!(0, gear.state());

pub fn next(&mut self) -> bool[src]

Increments the state if it's not at the end.

pub fn cycle(&mut self) -> bool[src]

Increments the state and resets if at end. Returns true if the gear has increments. Returns false if the gear has been reset to 0;

pub fn end(&self) -> bool[src]

Returns whether the gear is at it's last state.

pub fn reset(&mut self)[src]

Sets the gears state back to 0.

pub fn states(&self) -> &Vec<i32>[src]

Returns a reference to the entire states of the gear.

pub fn state(&self) -> i32[src]

Returns the current state of the gear.

Auto Trait Implementations

impl RefUnwindSafe for Gear

impl Send for Gear

impl Sync for Gear

impl Unpin for Gear

impl UnwindSafe for Gear

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.