pub struct MarketPrice { /* private fields */ }Expand description
A finite non-negative market price value.
Zero is accepted for descriptive use cases such as missing, halted, or placeholder prices.
Positive prices can be checked with MarketPrice::is_positive.
Implementations§
Source§impl MarketPrice
impl MarketPrice
Sourcepub fn new(value: f64) -> Result<MarketPrice, MarketPriceError>
pub fn new(value: f64) -> Result<MarketPrice, MarketPriceError>
Creates a market price from a finite non-negative f64.
§Errors
Returns MarketPriceError::NonFinite for NaN or infinite values and
MarketPriceError::Negative for negative values.
Sourcepub fn is_positive(self) -> bool
pub fn is_positive(self) -> bool
Returns whether the price is strictly positive.
Trait Implementations§
Source§impl Clone for MarketPrice
impl Clone for MarketPrice
Source§fn clone(&self) -> MarketPrice
fn clone(&self) -> MarketPrice
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for MarketPrice
Source§impl Debug for MarketPrice
impl Debug for MarketPrice
Source§impl Display for MarketPrice
impl Display for MarketPrice
Source§impl PartialEq for MarketPrice
impl PartialEq for MarketPrice
Source§fn eq(&self, other: &MarketPrice) -> bool
fn eq(&self, other: &MarketPrice) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for MarketPrice
impl PartialOrd for MarketPrice
impl StructuralPartialEq for MarketPrice
Source§impl TryFrom<f64> for MarketPrice
impl TryFrom<f64> for MarketPrice
Source§type Error = MarketPriceError
type Error = MarketPriceError
The type returned in the event of a conversion error.
Source§fn try_from(
value: f64,
) -> Result<MarketPrice, <MarketPrice as TryFrom<f64>>::Error>
fn try_from( value: f64, ) -> Result<MarketPrice, <MarketPrice as TryFrom<f64>>::Error>
Performs the conversion.
Auto Trait Implementations§
impl Freeze for MarketPrice
impl RefUnwindSafe for MarketPrice
impl Send for MarketPrice
impl Sync for MarketPrice
impl Unpin for MarketPrice
impl UnsafeUnpin for MarketPrice
impl UnwindSafe for MarketPrice
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