pub struct Chips(/* private fields */);Expand description
An exact chip amount, stored as a whole number of 1 / CHIP_SCALE chips.
Integer amounts make all-in detection, raise eligibility, and bet
deduplication exact, and keep the tree’s shape independent of the scale of
the inputs. Build one with Chips::whole or Chips::from_f64.
§Examples
use native_solver::Chips;
assert_eq!(Chips::from_f64(2.5), Some(Chips::whole(2) + Chips::from_f64(0.5).unwrap()));
assert_eq!(Chips::from_f64(0.0001), None); // finer than 1/1000 of a chip
assert_eq!(Chips::whole(3).to_string(), "3");Implementations§
Source§impl Chips
impl Chips
Sourcepub const fn whole(chips: i64) -> Chips
pub const fn whole(chips: i64) -> Chips
A whole number of input chips.
§Panics
Panics if the amount is larger than Chips::from_f64 accepts
(2^53 internal units, about 9 × 10^12 chips), in every build mode.
Sourcepub const fn from_units(units: i64) -> Chips
pub const fn from_units(units: i64) -> Chips
An amount in internal units of 1 / CHIP_SCALE input chips, so
Chips::from_units(CHIP_SCALE) is one chip.
Sourcepub fn from_f64(amount: f64) -> Option<Chips>
pub fn from_f64(amount: f64) -> Option<Chips>
Converts an amount of chips, if it is a whole number of 1 / CHIP_SCALE units.
Only f64 representation error is tolerated. Returns None for non-finite,
out-of-range, or finer-grained amounts rather than silently solving a
different game than the caller described.
Trait Implementations§
Source§impl AddAssign for Chips
impl AddAssign for Chips
Source§fn add_assign(&mut self, rhs: Chips)
fn add_assign(&mut self, rhs: Chips)
+= operation. Read moreimpl Copy for Chips
Source§impl Display for Chips
Decimal input chips with at most three fractional digits and no trailing
zeros (1.815, 0.5, 100), so distinct amounts never print alike.
impl Display for Chips
Decimal input chips with at most three fractional digits and no trailing
zeros (1.815, 0.5, 100), so distinct amounts never print alike.
impl Eq for Chips
Source§impl Ord for Chips
impl Ord for Chips
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Chips
impl PartialOrd for Chips
impl StructuralPartialEq for Chips
Auto Trait Implementations§
impl Forget for Chips
impl Freeze for Chips
impl Move for Chips
impl RefUnwindSafe for Chips
impl Send for Chips
impl Sync for Chips
impl Unpin for Chips
impl UnsafeUnpin for Chips
impl UnwindSafe for Chips
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more