Struct hanower::Interval[][src]

pub struct Interval { /* fields omitted */ }
Expand description

Used to create and work with intervals which are calculated from the user-input CLI values.

  • low is the starting point of the section from which to find intervals
  • high is the inclusive end point of the section from which to find intervals
  • count is the total number of desired intervals to be calculated
    • must be a minimum of 1 (prints interval of low to high)

Note: values are rounded to 12 significant decimal places.

Implementations

impl Interval[src]

pub fn new(low: f64, high: f64, count: u64) -> Result<Self, IntervalError>[src]

Creates a new Interval, with the range low..=high, split into count number of intervals.

pub fn low(&self) -> f64[src]

Returns the low value.

pub fn high(&self) -> f64[src]

Returns the high value.

pub fn count(&self) -> u64[src]

Returns the count value.

pub fn bucket(&self, number: f64) -> Option<usize>[src]

Finds the bucket a given value exists in.

A bucket refers to a range between two values, and including the starting value (similar to an interval).

For example, say we have values of low = 1, high = 10, and count = 5, and want to know which bucket the number 8 would be in. The output intervals would be 1 2 3 4 6 10. The first bucket is then 2..<3, next 3..<4, etc. So, 8 is in the fourth bucket, between 6 and 10.

pub fn iter(&self) -> IntervalIter

Notable traits for IntervalIter

impl Iterator for IntervalIter type Item = f64;
[src]

Returns an iterator of lazily evaluated intervals, starting from this Interval’s low value up to and including the high value.

pub fn intervals(&self) -> IntervalIter

Notable traits for IntervalIter

impl Iterator for IntervalIter type Item = f64;
[src]

Returns an iterator of lazily evaluated intervals based on the low and high points of this Interval.

Trait Implementations

impl Clone for Interval[src]

fn clone(&self) -> Interval[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Interval[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Copy for Interval[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.