Skip to content

std::steppable

Import with import std::steppable.

Interfaces

interface Steppable<S>
    fn step_by(value: self, by: S) -> Maybe<self>
end

The interface of values that can move by a step the caller gives.

Discrete.next is for types with a canonical next value. Steppable is for types where the caller supplies the step, such as Decimal values stepping by 0.1d or Codepoints stepping by an Int count.

fn step_by(value: self, by: S) -> Maybe<self>

interface Steppable

Returns value moved by by, or None when that step leaves the type’s valid domain.

Steppable.step_by(1, 2) // → Some(3)

Steppable.step_by(1.0d, 0.1d) // → Some(1.1d)