Skip to main content

step_number

Function step_number 

Source
pub fn step_number(
    current: &str,
    kind: NumberKind,
    step: &str,
    increment: bool,
) -> Result<String, InputError>
Expand description

Steps canonical text to the next zero-anchored multiple without clamping.

A step must be positive and representable by the bound primitive. An aligned value advances by one step. Floating-point inputs use their shortest decimal representations, independently of localized display formatting.

  • Complexity: O(current bytes + step bytes) time and space.

§Errors

Returns Lexical for malformed canonical text or nonpositive steps, TypeRange for nonfinite values, overflow, or an unrepresentable transition, and UnsupportedEditor for unknown widths.

§Examples

use adam_web_ui::{components::number::step_number, input::NumberKind};
assert_eq!(step_number("255", NumberKind::Unsigned(16), "1", true).unwrap(), "256");