pub struct DrainableBintCell {
pub capacity: Cell<usize>,
/* private fields */
}Expand description
Version of a BintCell that can only be called a limited number of times, after which it
returns none.
Fields§
§capacity: Cell<usize>Implementations§
Source§impl DrainableBintCell
impl DrainableBintCell
pub fn new(boundary: u8, capacity: usize) -> DrainableBintCell
Sourcepub fn new_with_value(
boundary: u8,
capacity: usize,
value: u8,
) -> DrainableBintCell
pub fn new_with_value( boundary: u8, capacity: usize, value: u8, ) -> DrainableBintCell
use bint::DrainableBintCell;
let b = DrainableBintCell::new_with_value(4, 4, 3);
assert_eq!(3, b.value());
assert_eq!(2, b.down().unwrap());
assert_eq!(1, b.down().unwrap());
assert_eq!(0, b.down().unwrap());
assert_eq!(3, b.down().unwrap());
assert!(b.down().is_none());Sourcepub fn down(&self) -> Option<u8>
pub fn down(&self) -> Option<u8>
use bint::DrainableBintCell;
let b = DrainableBintCell::new(4, 8);
assert_eq!(3, b.down().unwrap());
assert_eq!(2, b.down().unwrap());
assert_eq!(1, b.down().unwrap());
assert_eq!(0, b.down().unwrap());
assert_eq!(3, b.down().unwrap());
assert_eq!(2, b.down().unwrap());
assert_eq!(1, b.down().unwrap());
assert_eq!(0, b.down().unwrap());
assert!(b.down().is_none());Sourcepub fn down_x(&self, x: u8) -> Option<u8>
pub fn down_x(&self, x: u8) -> Option<u8>
use bint::DrainableBintCell;
let b = DrainableBintCell::new(4, 4);
assert_eq!(2, b.down_x(2).unwrap());
assert_eq!(0, b.down_x(2).unwrap());
assert!(b.down_x(2).is_none());Sourcepub fn has_capacity(&self) -> bool
pub fn has_capacity(&self) -> bool
use bint::DrainableBintCell;
let b = DrainableBintCell::new(1, 1);
assert!(b.has_capacity());
assert_eq!(0, b.up().unwrap());
assert!(!b.has_capacity());Sourcepub fn up(&self) -> Option<u8>
pub fn up(&self) -> Option<u8>
use bint::DrainableBintCell;
let b = DrainableBintCell::new(4, 4);
assert_eq!(1, b.up().unwrap());
assert_eq!(2, b.up().unwrap());
assert_eq!(3, b.up().unwrap());
assert_eq!(0, b.up().unwrap());
assert!(b.down().is_none());Sourcepub fn up_x(&self, x: u8) -> Option<u8>
pub fn up_x(&self, x: u8) -> Option<u8>
use bint::DrainableBintCell;
let b = DrainableBintCell::new(4, 4);
assert_eq!(3, b.up_x(3).unwrap());
assert_eq!(0, b.up_x(1).unwrap());
assert!(b.up_x(2).is_none());pub fn value(&self) -> u8
Trait Implementations§
Source§impl Clone for DrainableBintCell
impl Clone for DrainableBintCell
Source§fn clone(&self) -> DrainableBintCell
fn clone(&self) -> DrainableBintCell
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DrainableBintCell
impl Debug for DrainableBintCell
Source§impl From<&DrainableBintCell> for Bint
impl From<&DrainableBintCell> for Bint
Source§fn from(cell: &DrainableBintCell) -> Self
fn from(cell: &DrainableBintCell) -> Self
use bint::{Bint, DrainableBintCell};
let bint_cell = DrainableBintCell::new_with_value(8, 8, 3);
let expected = Bint::new_with_value(8, 3);
assert_eq!(expected, Bint::from(&bint_cell));Source§impl From<&DrainableBintCell> for BintCell
impl From<&DrainableBintCell> for BintCell
Source§fn from(cell: &DrainableBintCell) -> Self
fn from(cell: &DrainableBintCell) -> Self
use bint::{BintCell, DrainableBintCell};
let bint_cell = DrainableBintCell::new_with_value(8, 8, 3);
let expected = BintCell::new_with_value(8, 3);
assert_eq!(expected, BintCell::from(&bint_cell));Source§impl From<DrainableBintCell> for Bint
impl From<DrainableBintCell> for Bint
Source§fn from(cell: DrainableBintCell) -> Self
fn from(cell: DrainableBintCell) -> Self
use bint::{Bint, DrainableBintCell};
let bint_cell = DrainableBintCell::new_with_value(8, 8, 3);
let expected = Bint::new_with_value(8, 3);
assert_eq!(expected, Bint::from(bint_cell));Source§impl From<DrainableBintCell> for BintCell
impl From<DrainableBintCell> for BintCell
Source§fn from(cell: DrainableBintCell) -> Self
fn from(cell: DrainableBintCell) -> Self
use bint::{BintCell, DrainableBintCell};
let bint_cell = DrainableBintCell::new_with_value(8, 8, 3);
let expected = BintCell::new_with_value(8, 3);
assert_eq!(expected, BintCell::from(bint_cell));Source§impl Ord for DrainableBintCell
impl Ord for DrainableBintCell
Source§fn cmp(&self, other: &DrainableBintCell) -> Ordering
fn cmp(&self, other: &DrainableBintCell) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for DrainableBintCell
impl PartialEq for DrainableBintCell
Source§impl PartialOrd for DrainableBintCell
impl PartialOrd for DrainableBintCell
impl Eq for DrainableBintCell
impl StructuralPartialEq for DrainableBintCell
Auto Trait Implementations§
impl !Freeze for DrainableBintCell
impl !RefUnwindSafe for DrainableBintCell
impl Send for DrainableBintCell
impl !Sync for DrainableBintCell
impl Unpin for DrainableBintCell
impl UnwindSafe for DrainableBintCell
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