#literals #macros #primitive #extra #internal #types #nightly #u128 #i128

macro extprim_literals_macros

Internal crate to support extprim_literals. You typically don’t need this crate directly.

3 stable releases

Uses old Rust 2015

2.0.3 Jul 11, 2017
2.0.2 Jun 16, 2017
2.0.0 Mar 18, 2017

#1040 in Procedural macros

Download history 4/week @ 2021-10-06 8/week @ 2021-10-13 3/week @ 2021-10-20 18/week @ 2021-10-27 31/week @ 2021-11-03 28/week @ 2021-11-10 35/week @ 2021-11-17 32/week @ 2021-11-24 35/week @ 2021-12-01 32/week @ 2021-12-08 27/week @ 2021-12-15 28/week @ 2021-12-22 30/week @ 2021-12-29 33/week @ 2022-01-05 40/week @ 2022-01-12 26/week @ 2022-01-19

133 downloads per month
Used in 3 crates (via extprim_literals)

MIT/Apache

195KB
3.5K SLoC

extprim

Travis (Linux and OS X) Build status AppVeyor (Windows) Build status Coverage Status crates.io MIT / Apache 2.0

Thanks to RFC 1504 “int128”, you can use i128 and u128 directly on nightly Rust starting from 1.16. Using the built-in types are preferred.

Extra primitive types for stable Rust. Currently includes:

  • u128 (unsigned 128-bit integers)
  • i128 (signed 128-bit integers)

Documentation

You may also find other primitive types in other crates:

Usage

# Cargo.toml
[dependencies]
extprim = "1"

If you want to use the u128!() and i128!() macros, please include the extprim_literals plugin.

# Cargo.toml
[dependencies]
extprim = "1"
extprim_literals = "2"

Example

#[macro_use]
extern crate extprim_literals;
extern crate extprim;

use std::str::FromStr;
use extprim::i128::i128;

fn main() {
    let a = i128::from_str("100000000000000000000000000000000000000").unwrap();
            // convert string to u128 or i128
    let b = i128::new(10).pow(38);
            // 64-bit integers can be directly new'ed
    assert_eq!(a, b);

    let c = i128::from_parts(5421010862427522170, 687399551400673280);
            // represent using the higher- and lower-64-bit parts
    let d = c - a;
            // standard operators like +, -, *, /, %, etc. work as expected.
    assert_eq!(d, i128::zero());

    const e: i128 = i128!(100000000000000000000000000000000000000);
            // use the literal macros
    assert_eq!(a, e);
}

Dependencies

~1–1.7MB
~35K SLoC