Crate numext_fixed_uint

Source
Expand description

A series of fixed non-negative integer types.

§Constructors

This crate provides a series of macros that used to construct fixed uints in compile time.

The input is a string literal, and the macros support several formats of the input:

  • A decimal string.
  • A binary string with 0b prefix.
  • A octal string with 0o prefix.
  • A hexadecimal string with 0x prefix.

And you can use any number of _ in the string literal to separate it for more readable.

§Examples

use numext_fixed_uint::{u128, U128};

const U128_100: U128 = u128!("100");

fn main () -> ::std::io::Result<()> {
    let x1 = u128!("0b110_0100");
    let x2 = u128!("0o144");
    let x3 = u128!("0x64");
    let y = U128::from(100u8);
    assert_eq!(x1, y);
    assert_eq!(x2, y);
    assert_eq!(x3, y);
    assert_eq!(U128_100, y);
    Ok(())
}

Modules§

prelude

Macros§

u128
A macro used to construct a fixed uint in compile time.
u160
A macro used to construct a fixed uint in compile time.
u224
A macro used to construct a fixed uint in compile time.
u256
A macro used to construct a fixed uint in compile time.
u384
A macro used to construct a fixed uint in compile time.
u512
A macro used to construct a fixed uint in compile time.
u520
A macro used to construct a fixed uint in compile time.
u1024
A macro used to construct a fixed uint in compile time.
u2048
A macro used to construct a fixed uint in compile time.
u4096
A macro used to construct a fixed uint in compile time.

Structs§

U128
Fixed non-negative integer type.
U160
Fixed non-negative integer type.
U224
Fixed non-negative integer type.
U256
Fixed non-negative integer type.
U384
Fixed non-negative integer type.
U512
Fixed non-negative integer type.
U520
Fixed non-negative integer type.
U1024
Fixed non-negative integer type.
U2048
Fixed non-negative integer type.
U4096
Fixed non-negative integer type.

Enums§

FixedUintError
FromSliceError
Error for parse from slice.
FromStrError
Error for parse from string.
IntoSliceError
Error for parse from slice.