num-primitive 0.1.0

Traits for primitive numeric types
Documentation
  • Coverage
  • 100%
    214 out of 214 items documented5 out of 5 items with examples
  • Size
  • Source code size: 91.24 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 11.83 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • rust-num/num-primitive
    2 2 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • cuviper

num-primitive

crate documentation minimum rustc 1.85 build status

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:

  • PrimitiveNumber
    • PrimitiveFloat: f32 and f64
    • PrimitiveInteger
      • PrimitiveSigned: i8, i16, i32, i64, i128, and isize
      • PrimitiveUnsigned: u8, u16, u32, u64, u128, and usize

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.

Releases

Release notes are available in RELEASES.md.

Compatibility

The num-primitive crate is currently tested for Rust 1.85 and greater. This minimum-supported Rust version (MSRV) may be increased at any time to add support for newly-stabilized functionality from the standard library. Changes will be documented prominently in the release notes.

If you have specific MSRV needs for your dependent crate, then take care when choosing your num-primitive minimum version, and use Cargo's version-aware resolver to automatically limit your maximum. This way you'll still leave it open for further dependent projects that do want newer version for new features.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.