pub struct PercentFloat(/* private fields */);Expand description
Percentage value as f64 in the range 0.0..=100.0.
Use this when decimal precision is required. For integer percentages, use
Percent.
Implementations§
Source§impl PercentFloat
impl PercentFloat
Sourcepub fn new(value: f64) -> PrimitiveResult<Self>
pub fn new(value: f64) -> PrimitiveResult<Self>
Creates a PercentFloat. Returns Invalid if value is not finite
or is outside 0.0..=100.0.
Sourcepub fn as_fraction(self) -> f64
pub fn as_fraction(self) -> f64
Returns the value as a fraction between 0.0 and 1.0.
Trait Implementations§
Source§impl Clone for PercentFloat
impl Clone for PercentFloat
Source§fn clone(&self) -> PercentFloat
fn clone(&self) -> PercentFloat
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 PercentFloat
Source§impl Debug for PercentFloat
impl Debug for PercentFloat
Source§impl Display for PercentFloat
impl Display for PercentFloat
Source§impl PartialEq for PercentFloat
impl PartialEq for PercentFloat
Source§fn eq(&self, other: &PercentFloat) -> bool
fn eq(&self, other: &PercentFloat) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for PercentFloat
impl PartialOrd for PercentFloat
impl StructuralPartialEq for PercentFloat
Auto Trait Implementations§
impl Freeze for PercentFloat
impl RefUnwindSafe for PercentFloat
impl Send for PercentFloat
impl Sync for PercentFloat
impl Unpin for PercentFloat
impl UnsafeUnpin for PercentFloat
impl UnwindSafe for PercentFloat
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