Struct incr::Incr [−][src]
pub struct Incr(_);
A self-contained struct for quickly checking whether a newly observed value is greater than any previously observed value.
Examples
use incr::Incr; let mut last = Incr::default(); assert_eq!(last.is_new(1), true); assert_eq!(last.is_new(1), false); assert_eq!(last.is_new(2), true); assert_eq!(last.get(), 2);
Methods
impl Incr
[src]
impl Incr
pub fn is_new(&mut self, val: u64) -> bool
[src]
pub fn is_new(&mut self, val: u64) -> bool
Returns true
if val
is greater than the highest previously observed
value. If val
is a new maximum, it is stored in self
for checks against
future values subsequent calls Self::get(&self)
will return val
until a
new max is observed.
pub fn get(&self) -> u64
[src]
pub fn get(&self) -> u64
Returns the current value of self
, which is the maximum observed value.
Trait Implementations
impl Default for Incr
[src]
impl Default for Incr
impl Clone for Incr
[src]
impl Clone for Incr
fn clone(&self) -> Incr
[src]
fn clone(&self) -> Incr
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl PartialEq for Incr
[src]
impl PartialEq for Incr
fn eq(&self, other: &Incr) -> bool
[src]
fn eq(&self, other: &Incr) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Incr) -> bool
[src]
fn ne(&self, other: &Incr) -> bool
This method tests for !=
.
impl PartialOrd for Incr
[src]
impl PartialOrd for Incr
fn partial_cmp(&self, other: &Incr) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Incr) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Incr) -> bool
[src]
fn lt(&self, other: &Incr) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Incr) -> bool
[src]
fn le(&self, other: &Incr) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Incr) -> bool
[src]
fn gt(&self, other: &Incr) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Incr) -> bool
[src]
fn ge(&self, other: &Incr) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Eq for Incr
[src]
impl Eq for Incr
impl Debug for Incr
[src]
impl Debug for Incr
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl From<u64> for Incr
[src]
impl From<u64> for Incr