pub struct Trend {
pub current: f64,
pub previous: f64,
}Expand description
Comparison of a metric against an earlier period.
Fields§
§current: f64§previous: f64Implementations§
Source§impl Trend
impl Trend
pub fn new(current: f64, previous: f64) -> Self
Sourcepub fn change_ratio(&self) -> Option<f64>
pub fn change_ratio(&self) -> Option<f64>
Relative change, e.g. -0.4 for a 40 % drop.
Returns None when the previous value is zero — there is no meaningful
percentage change from nothing, and reporting +∞ % in the UI is worse than
reporting nothing.
Trait Implementations§
impl Copy for Trend
Source§impl<'de> Deserialize<'de> for Trend
impl<'de> Deserialize<'de> for Trend
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Trend
Auto Trait Implementations§
impl Freeze for Trend
impl RefUnwindSafe for Trend
impl Send for Trend
impl Sync for Trend
impl Unpin for Trend
impl UnsafeUnpin for Trend
impl UnwindSafe for Trend
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