pub struct CentsUnsigned(/* private fields */);Expand description
Unsigned cents (u64) - for values that should never be negative. Used for invested capital, realized cap, etc.
Implementations§
Source§impl CentsUnsigned
impl CentsUnsigned
pub const ZERO: CentsUnsigned
pub const MAX: CentsUnsigned
pub const fn new(value: u64) -> CentsUnsigned
pub const fn inner(self) -> u64
pub const fn as_u128(self) -> u128
pub fn checked_sub(self, rhs: CentsUnsigned) -> Option<CentsUnsigned>
pub fn saturating_sub(self, rhs: CentsUnsigned) -> CentsUnsigned
pub fn checked_add(self, rhs: CentsUnsigned) -> Option<CentsUnsigned>
pub fn to_dollars(self) -> Dollars
Sourcepub fn round_to(self, digits: i32) -> CentsUnsigned
pub fn round_to(self, digits: i32) -> CentsUnsigned
Round to N significant digits. E.g., 12345 (= $123.45) with round_to(4) → 12350 (= $123.50) E.g., 12345 (= $123.45) with round_to(3) → 12300 (= $123.00)
Sourcepub fn round_to_dollar(self, digits: i32) -> CentsUnsigned
pub fn round_to_dollar(self, digits: i32) -> CentsUnsigned
Round to nearest dollar, then apply N significant digits. E.g., 12345 (= $123.45) → 12300 (= $123.00) with 5 digits E.g., 1234567 (= $12345.67) → 1234600 (= $12346.00) with 5 digits
Trait Implementations§
Source§impl Add for CentsUnsigned
impl Add for CentsUnsigned
Source§type Output = CentsUnsigned
type Output = CentsUnsigned
The resulting type after applying the
+ operator.Source§fn add(self, rhs: CentsUnsigned) -> <CentsUnsigned as Add>::Output
fn add(self, rhs: CentsUnsigned) -> <CentsUnsigned as Add>::Output
Performs the
+ operation. Read moreSource§impl AddAssign for CentsUnsigned
impl AddAssign for CentsUnsigned
Source§fn add_assign(&mut self, rhs: CentsUnsigned)
fn add_assign(&mut self, rhs: CentsUnsigned)
Performs the
+= operation. Read moreSource§impl Bytes for CentsUnsigned
impl Bytes for CentsUnsigned
Source§type Array = <u64 as Bytes>::Array
type Array = <u64 as Bytes>::Array
The byte array type returned by
to_bytes.
For fixed-size types, this is [u8; N] where N is the size of the type.Source§fn to_bytes(&self) -> <CentsUnsigned as Bytes>::Array
fn to_bytes(&self) -> <CentsUnsigned as Bytes>::Array
Serializes this value to bytes. Read more
Source§fn from_bytes(bytes: &[u8]) -> Result<CentsUnsigned, Error>
fn from_bytes(bytes: &[u8]) -> Result<CentsUnsigned, Error>
Deserializes a value from bytes. Read more
Source§impl Clone for CentsUnsigned
impl Clone for CentsUnsigned
Source§fn clone(&self) -> CentsUnsigned
fn clone(&self) -> CentsUnsigned
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 CentsUnsigned
impl Debug for CentsUnsigned
Source§impl Default for CentsUnsigned
impl Default for CentsUnsigned
Source§fn default() -> CentsUnsigned
fn default() -> CentsUnsigned
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for CentsUnsigned
impl<'de> Deserialize<'de> for CentsUnsigned
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<CentsUnsigned, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<CentsUnsigned, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for CentsUnsigned
impl Display for CentsUnsigned
Source§impl Div<u64> for CentsUnsigned
impl Div<u64> for CentsUnsigned
Source§impl Div<usize> for CentsUnsigned
impl Div<usize> for CentsUnsigned
Source§impl Div for CentsUnsigned
impl Div for CentsUnsigned
Source§type Output = CentsUnsigned
type Output = CentsUnsigned
The resulting type after applying the
/ operator.Source§fn div(self, rhs: CentsUnsigned) -> <CentsUnsigned as Div>::Output
fn div(self, rhs: CentsUnsigned) -> <CentsUnsigned as Div>::Output
Performs the
/ operation. Read moreSource§impl Formattable for CentsUnsigned
impl Formattable for CentsUnsigned
Source§impl From<CentsUnsigned> for CentsUnsignedCompact
impl From<CentsUnsigned> for CentsUnsignedCompact
Source§fn from(value: CentsUnsigned) -> CentsUnsignedCompact
fn from(value: CentsUnsigned) -> CentsUnsignedCompact
Converts to this type from the input type.
Source§impl From<CentsUnsigned> for Dollars
impl From<CentsUnsigned> for Dollars
Source§fn from(value: CentsUnsigned) -> Dollars
fn from(value: CentsUnsigned) -> Dollars
Converts to this type from the input type.
Source§impl From<CentsUnsigned> for f64
impl From<CentsUnsigned> for f64
Source§fn from(value: CentsUnsigned) -> f64
fn from(value: CentsUnsigned) -> f64
Converts to this type from the input type.
Source§impl From<CentsUnsigned> for u64
impl From<CentsUnsigned> for u64
Source§fn from(value: CentsUnsigned) -> u64
fn from(value: CentsUnsigned) -> u64
Converts to this type from the input type.
Source§impl From<CentsUnsignedCompact> for CentsUnsigned
impl From<CentsUnsignedCompact> for CentsUnsigned
Source§fn from(value: CentsUnsignedCompact) -> CentsUnsigned
fn from(value: CentsUnsignedCompact) -> CentsUnsigned
Converts to this type from the input type.
Source§impl From<Dollars> for CentsUnsigned
impl From<Dollars> for CentsUnsigned
Source§fn from(value: Dollars) -> CentsUnsigned
fn from(value: Dollars) -> CentsUnsigned
Converts to this type from the input type.
Source§impl From<f64> for CentsUnsigned
impl From<f64> for CentsUnsigned
Source§fn from(value: f64) -> CentsUnsigned
fn from(value: f64) -> CentsUnsigned
Converts to this type from the input type.
Source§impl From<u128> for CentsUnsigned
impl From<u128> for CentsUnsigned
Source§fn from(value: u128) -> CentsUnsigned
fn from(value: u128) -> CentsUnsigned
Converts to this type from the input type.
Source§impl From<u64> for CentsUnsigned
impl From<u64> for CentsUnsigned
Source§fn from(value: u64) -> CentsUnsigned
fn from(value: u64) -> CentsUnsigned
Converts to this type from the input type.
Source§impl From<usize> for CentsUnsigned
impl From<usize> for CentsUnsigned
Source§fn from(value: usize) -> CentsUnsigned
fn from(value: usize) -> CentsUnsigned
Converts to this type from the input type.
Source§impl Hash for CentsUnsigned
impl Hash for CentsUnsigned
Source§impl JsonSchema for CentsUnsigned
impl JsonSchema for CentsUnsigned
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl Mul<Sats> for CentsUnsigned
impl Mul<Sats> for CentsUnsigned
Source§impl Mul<u64> for CentsUnsigned
impl Mul<u64> for CentsUnsigned
Source§impl Mul<usize> for CentsUnsigned
impl Mul<usize> for CentsUnsigned
Source§impl Mul for CentsUnsigned
impl Mul for CentsUnsigned
Source§type Output = CentsUnsigned
type Output = CentsUnsigned
The resulting type after applying the
* operator.Source§fn mul(self, rhs: CentsUnsigned) -> <CentsUnsigned as Mul>::Output
fn mul(self, rhs: CentsUnsigned) -> <CentsUnsigned as Mul>::Output
Performs the
* operation. Read moreSource§impl Ord for CentsUnsigned
impl Ord for CentsUnsigned
Source§fn cmp(&self, other: &CentsUnsigned) -> Ordering
fn cmp(&self, other: &CentsUnsigned) -> 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 CentsUnsigned
impl PartialEq for CentsUnsigned
Source§impl PartialOrd for CentsUnsigned
impl PartialOrd for CentsUnsigned
Source§impl Pco for CentsUnsigned
impl Pco for CentsUnsigned
type NumberType = <u64 as Pco>::NumberType
Source§impl Serialize for CentsUnsigned
impl Serialize for CentsUnsigned
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Source§impl Sub for CentsUnsigned
impl Sub for CentsUnsigned
Source§type Output = CentsUnsigned
type Output = CentsUnsigned
The resulting type after applying the
- operator.Source§fn sub(self, rhs: CentsUnsigned) -> <CentsUnsigned as Sub>::Output
fn sub(self, rhs: CentsUnsigned) -> <CentsUnsigned as Sub>::Output
Performs the
- operation. Read moreSource§impl SubAssign for CentsUnsigned
impl SubAssign for CentsUnsigned
Source§fn sub_assign(&mut self, rhs: CentsUnsigned)
fn sub_assign(&mut self, rhs: CentsUnsigned)
Performs the
-= operation. Read moreimpl Copy for CentsUnsigned
impl Eq for CentsUnsigned
impl StructuralPartialEq for CentsUnsigned
impl TransparentPco<<u64 as Pco>::NumberType> for CentsUnsigned
Auto Trait Implementations§
impl Freeze for CentsUnsigned
impl RefUnwindSafe for CentsUnsigned
impl Send for CentsUnsigned
impl Sync for CentsUnsigned
impl Unpin for CentsUnsigned
impl UnwindSafe for CentsUnsigned
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> FromInnerSlice<<T as Pco>::NumberType> for Twhere
T: PcoVecValue,
impl<T> FromInnerSlice<<T as Pco>::NumberType> for Twhere
T: PcoVecValue,
const _SIZE_CHECK: ()
const _ALIGN_CHECK: ()
fn from_inner_slice(vec: Vec<<T as Pco>::NumberType>) -> Vec<T>
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>
Converts
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>
Converts
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