Crate easy_cast[−][src]
Type conversion, success expected
From
andInto
are not enough- it is expected that the value can be represented exactly by the target type
- you could use
as
, but want some assurance it’s doing the right thing - you are converting numbers (future versions might consider supporting other conversions)
Use ConvFloat
and CastFloat
when:
- You are converting from
f32
orf64
- You specifically want the nearest or ceiling or floor, but don’t need detailed control over rounding (e.g. round-to-even)
Assertions
All type conversions which are potentially fallible assert on failure in debug builds. In release builds assertions may be omitted, thus making incorrect conversions possible.
If the always_assert
feature flag is set, assertions will be turned on in
all builds. Some additional feature flags are available for finer-grained
control (see Cargo.toml
).
Traits
Cast | |
CastFloat | |
Conv | Like |
ConvFloat | Nearest / floor / ceil conversions from floating point types |