Struct libnotcurses_sys::examples::utils::Counter[][src]

pub struct Counter {
    pub starting: isize,
    pub current: isize,
    pub step: isize,
    pub limit: Option<isize>,
}
Expand description

A little versatile Counter.

Fields

starting: isize

The starting value.

current: isize

The current value.

step: isize

The amount to increase the current value on each update, until it reaches its limit.

limit: Option<isize>

An optional limit value that, when reached, will prevent further updating the counter.

If set, it must have the same sign as the step. If not set, the natural limit will be |isize::MAX|.

Implementations

Returns a new Counter.

Note that limit and step must be both positive or negative together.

If a limit value has been set, returns true when the counter has reached its limit value, and if not, increments its current value.

If there’s no limit value, always returns false while incrementing the current value.

Like update but wraps the value if it reaches the limit.

Returns true if the counter has reached its limit value.

When there’s no limit, it will always return false.

Returns the current value, and sets it at the starting value.

Trait Implementations

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.