Skip to main content

Numeric

Trait Numeric 

Source
pub trait Numeric:
    Copy
    + PartialOrd
    + Display {
    const KIND: &'static str;

    // Required methods
    fn read(raw: &str) -> Option<(Self, Value)>;
    fn divisible_by(self, step: Self) -> bool;
}
Expand description

The two number kinds a document can ask one flag for.

A trait rather than two copies of Bounds and its rules: the comparisons are the same sentence in both, and only reading a value out of an argument and dividing by one differ. It is public because Bounds is, and there is no third kind to implement it for — i64 and f64 are what OpenAPI’s integer and number are.

Required Associated Constants§

Source

const KIND: &'static str

What a refusal calls this kind.

Required Methods§

Source

fn read(raw: &str) -> Option<(Self, Value)>

This kind read out of one argument, with the JSON it goes out as.

One step, because the two can disagree: a float that parses but is not finite is not a number JSON carries, and “is not a number” is the honest answer rather than a null on the wire.

Source

fn divisible_by(self, step: Self) -> bool

multipleOf: whether dividing by step leaves a whole number.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Numeric for f64

Source§

const KIND: &'static str = "a number"

Source§

fn read(raw: &str) -> Option<(Self, Value)>

Source§

fn divisible_by(self, step: Self) -> bool

Source§

impl Numeric for i64

Source§

const KIND: &'static str = "an integer"

Source§

fn read(raw: &str) -> Option<(Self, Value)>

Source§

fn divisible_by(self, step: Self) -> bool

Implementors§