pub struct SimpleReturn { /* private fields */ }Expand description
A finite simple return value.
Implementations§
Source§impl SimpleReturn
impl SimpleReturn
Sourcepub fn new(value: f64) -> Result<Self, ReturnError>
pub fn new(value: f64) -> Result<Self, ReturnError>
Creates a simple return from a finite value.
§Errors
Returns ReturnError::NonFiniteReturn when value is not finite.
Sourcepub fn from_prices(
start_price: f64,
end_price: f64,
) -> Result<Self, ReturnError>
pub fn from_prices( start_price: f64, end_price: f64, ) -> Result<Self, ReturnError>
Computes a simple return as end_price / start_price - 1.0.
§Errors
Returns ReturnError when either price is not finite, the start price is not positive,
or the end price is negative.
Trait Implementations§
Source§impl Clone for SimpleReturn
impl Clone for SimpleReturn
Source§fn clone(&self) -> SimpleReturn
fn clone(&self) -> SimpleReturn
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 SimpleReturn
impl Debug for SimpleReturn
Source§impl Display for SimpleReturn
impl Display for SimpleReturn
Source§impl PartialEq for SimpleReturn
impl PartialEq for SimpleReturn
Source§impl PartialOrd for SimpleReturn
impl PartialOrd for SimpleReturn
impl Copy for SimpleReturn
impl StructuralPartialEq for SimpleReturn
Auto Trait Implementations§
impl Freeze for SimpleReturn
impl RefUnwindSafe for SimpleReturn
impl Send for SimpleReturn
impl Sync for SimpleReturn
impl Unpin for SimpleReturn
impl UnsafeUnpin for SimpleReturn
impl UnwindSafe for SimpleReturn
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