js_int 0.1.0

JavaScript-interoperable integer types
Documentation

js_int

Build Status Latest Version Docs

Crate js_int provides JavaScript-interoperable integer types.

JavaScript does not have native integers. Instead it represents all numeric values with a single Number type which is represented as an IEEE 754 floating-point value. Rust's i64 and u64 types can contain values outside the range of what can be represented in a JavaScript Number.

This crate provides the types Int and UInt which wrap i64 and u64, respectively. These types add bounds checking to ensure the contained value is within the range representable by a JavaScript Number. They provide useful trait implementations to easily convert from Rust's primitive integer types.

This crate is no_std-compatible with default-features = false. This will disable the std feature, which at the time of writing will only omit the implementation of std::error::Error for TryFromIntError.

(De-)Serialization via serde is supported via the serde feature, even without the std feature.