Crate num_primitive

Crate num_primitive 

Source
Expand description

§num-primitive

Traits for primitive numeric types in Rust.

These traits provide a simple hierarchy for generic programming with Rust’s primitive floating-point and integer types:

Each trait includes supertraits for everything implemented in common by these types, as well as associated constants and methods matching their inherent items. PrimitiveFloat also adds the contents of core::{float}::consts.

It is not a goal of this crate to add any functionality to the primitive types, only to expose what is already available in the standard library in a more generic way. The traits are also sealed against downstream implementations to allow expansion in a non-breaking way.

For use-cases that include third-party types, along with features that go beyond the standard library, consider crates like num-traits and num-integer.

§Usage

Add this to your Cargo.toml:

[dependencies]
num-primitive = "0.1"

§Features

This crate can be used without the standard library (#![no_std]) by disabling the default std feature. Use this in Cargo.toml:

[dependencies.num-primitive]
version = "0.1"
default-features = false

Some PrimitiveFloat methods are only available when the std feature is enabled, just like when using those floating-point types directly.

Traits§

PrimitiveError
Trait for errors that may be returned in numeric conversions.
PrimitiveFloat
Trait for all primitive floating-point types, including the supertrait PrimitiveNumber.
PrimitiveFloatRef
Trait for references to primitive floating-point types (PrimitiveFloat).
PrimitiveFloatToInt
Trait for conversions supported by PrimitiveFloat::to_int_unchecked.
PrimitiveInteger
Trait for all primitive integer types, including the supertrait PrimitiveNumber.
PrimitiveIntegerRef
Trait for references to primitive integer types (PrimitiveInteger).
PrimitiveNumber
Trait for all primitive numeric types.
PrimitiveNumberRef
Trait for references to primitive numbers (PrimitiveNumber).
PrimitiveSigned
Trait for all primitive signed integer types, including the supertraits PrimitiveInteger and PrimitiveNumber.
PrimitiveSignedRef
Trait for references to primitive signed integer types (PrimitiveSigned).
PrimitiveUnsigned
Trait for all primitive unsigned integer types, including the supertraits PrimitiveInteger and PrimitiveNumber.
PrimitiveUnsignedRef
Trait for references to primitive unsigned integer types (PrimitiveUnsigned).