[−][src]Crate js_int
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.
#![no_std]
The js_int
crate does not use Rust's standard library, and is compatible with #![no_std]
programs.
Features
rocket_04
: Deserialization support from form values (impl FromFormValue
) and path segments (impl FromParam
) for users of the Rocket web framework version 0.4. Disabled by default.serde
: Serialization and deserialization support via serde. Disabled by default. You can usejs_int
+serde
in#![no_std]
contexts if you usedefault-features = false
for both.std
: Enablestd::error::Error
implementations forParseIntError
,TryFromIntError
. Enabled by default.
Structs
Int | An integer limited to the range of integers that can be represented exactly by an f64. |
ParseIntError | The error type returned when when parsing an integer fails. |
TryFromIntError | The error type returned when a checked integral type conversion fails. |
UInt | An integer limited to the range of non-negative integers that can be represented exactly by an f64. |
Constants
MAX_SAFE_INT | The largest integer value that can be represented exactly by an f64. |
MAX_SAFE_UINT | The same as |
MIN_SAFE_INT | The smallest integer value that can be represented exactly by an f64. |