pub trait CastFromSlice<From> {
// Required method
fn cast_from_slice(self, from: From);
}Expand description
Perform a numeric cast on a slice of values.
This trait is intended to have the following numerical behavior:
- If a lossless conversion between types is available, use that.
- Otherwise, if the two type are floating point types, use a round-to-nearest strategy.
- Otherwise, try to behave like the Rust
asnumeric cast.
The main reason we can’t just say “behave like “as”“ is because Rust does not have
a native f16 type, which this crate supports.