pub struct BintCell {
pub cell: Cell<u8>,
pub boundary: u8,
}Expand description
BintCell: A bounded integer captured in a Cell.
Allows for Bint functionality in a single entity.
Usage:
use bint::BintCell;
let b = BintCell::new(6);
b.down();
assert_eq!(5, b.value());
b.up();
b.up();
b.up();
assert_eq!(2, b.value());Fields§
§cell: Cell<u8>§boundary: u8Implementations§
Source§impl BintCell
impl BintCell
Sourcepub fn new(boundary: u8) -> BintCell
pub fn new(boundary: u8) -> BintCell
use bint::BintCell;
let b = BintCell::new(6);
assert_eq!(0, b.value());
assert_eq!(6, b.boundary);Sourcepub fn new_with_value(boundary: u8, value: u8) -> BintCell
pub fn new_with_value(boundary: u8, value: u8) -> BintCell
use bint::BintCell;
let b = BintCell::new_with_value(6, 6);
assert_eq!(0, b.value());
assert_eq!(6, b.boundary);
let b = BintCell::new_with_value(6, 3);
assert_eq!(3, b.value());
assert_eq!(6, b.boundary);Sourcepub fn up(&self)
pub fn up(&self)
use bint::BintCell;
let b = BintCell::new(6);
b.up();
assert_eq!(1, b.value());
b.up();
assert_eq!(2, b.value());Sourcepub fn up_x(&self, x: u8)
pub fn up_x(&self, x: u8)
use bint::BintCell;
let b = BintCell::new(6);
b.up_x(3);
assert_eq!(3, b.value());Sourcepub fn down(&self)
pub fn down(&self)
use bint::BintCell;
let b = BintCell::new(6);
b.down();
assert_eq!(5, b.value());
b.down();
assert_eq!(4, b.value());Sourcepub fn down_x(&self, x: u8)
pub fn down_x(&self, x: u8)
use bint::BintCell;
let b = BintCell::new(6);
b.down_x(2);
assert_eq!(4, b.value());Sourcepub fn reset(&self)
pub fn reset(&self)
use bint::BintCell;
let b = BintCell::new_with_value(8, 5);
b.reset();
assert_eq!(0, b.value());Sourcepub fn set(&self, value: u8)
pub fn set(&self, value: u8)
use bint::BintCell;
let b = BintCell::new(8);
b.set(5);
assert_eq!(5, b.value());pub fn value(&self) -> u8
Trait Implementations§
Source§impl Ord for BintCell
impl Ord for BintCell
Source§impl PartialOrd for BintCell
impl PartialOrd for BintCell
impl Eq for BintCell
impl StructuralPartialEq for BintCell
Auto Trait Implementations§
impl !Freeze for BintCell
impl !RefUnwindSafe for BintCell
impl Send for BintCell
impl !Sync for BintCell
impl Unpin for BintCell
impl UnwindSafe for BintCell
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more