[−][src]Struct gear_combos::Gear
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,