docs

你正在阅读 v0.1.0 的文档。Nabi 0.1.0 已不再提供支持。 最新版本:v0.1.3 →

core::num::niche

本页内容

API 参考只有英文版,由标准库源代码中的英文文档注释生成。

wrappers that leave out values: NonZero<T> (0), NonNan<F> (NaN), Finite<F> (NaN, +/-inf), Positive<T> (negatives). Each is a #[niche(..)] newtype, so NonZero<i32> | none is 4 bytes and NonNan<f64> | none 8. new checks; new_unchecked is unsafe: a left-out value in one reads as none once it is in a sum.

Structs

ZeroErrorSource

pub struct ZeroError

What NonZero::try_from(0) throws.

  • pub const fn message(self) -> str§

    Source

    What went wrong, for display.

Trait implementations 3
  • impl Display for ZeroError
  • impl Debug for ZeroError
  • impl Error for ZeroError

NonZeroSource

pub struct NonZero<T>(T)

A T that is never 0; C passes it as T.

  • pub const fn new(value: T) -> NonZero<T> | none§

    Source

    value as a NonZero; none when it is 0.

  • pub const unsafe fn new_unchecked(value: T) -> NonZero<T>§

    Source

    value must not be 0.

  • pub const fn get(self) -> T§

    Source

    The value.

Trait implementations 14

PositiveSource

pub struct Positive<T>(T)

A T that is never negative. Positive<u*> has no negatives, so it has no niche either.

  • pub const fn new(value: T) -> Positive<T> | none§

    Source

    value as a Positive; none when it is negative.

  • pub unsafe fn new_unchecked(value: T) -> Positive<T>§

    Source

    value must not be negative.

  • pub const fn get(self) -> T§

    Source

    The value.

Trait implementations 10

NonNanSource

pub struct NonNan<F>(F)

An F that is never NaN: totally ordered, so Eq / Ord / Hash (-0.0 == 0.0, and they hash alike).

  • pub const fn new(value: F) -> NonNan<F> | none§

    Source

    value as a NonNan; none when it is NaN.

  • pub unsafe fn new_unchecked(value: F) -> NonNan<F>§

    Source

    value must not be NaN.

  • pub fn get(self) -> F§

    Source

    The wrapped float.

Trait implementations 14

FiniteSource

pub struct Finite<F>(F)

An F that is neither NaN nor +/-inf.

  • pub const fn new(value: F) -> Finite<F> | none§

    Source

    value as a Finite; none when it is NaN or +/-inf.

  • pub unsafe fn new_unchecked(value: F) -> Finite<F>§

    Source

    value must be finite.

  • pub fn get(self) -> F§

    Source

    The wrapped float.

Trait implementations 13

Traits

NicheIntSource

pub trait NicheInt: Zero + Copy + Ord + Hash + Display + Debug + Add<Output = Self> + Sub<Output = Self> + Mul<Output = Self> + Div<Output = Self>

The integer types NonZero / Positive wrap.

NicheFloatSource

pub trait NicheFloat: Copy + PartialOrd + Display + Debug + Add<Output = Self> + Sub<Output = Self> + Mul<Output = Self> + Div<Output = Self>

The float types NonNan / Finite wrap.