commit | c83b0310de8faabd23970489c8a280d59db00204 | [log] [tgz] |
---|---|---|
author | James Farrell <[email protected]> | Thu Aug 15 01:51:02 2024 +0000 |
committer | Automerger Merge Worker <[email protected]> | Thu Aug 15 01:51:02 2024 +0000 |
tree | ffdc4526e3d0d51ce1f669826c39c8e3981ec6dc | |
parent | 7e0fd2e68d03cc376e82c3166b2c891c11fc8b76 [diff] | |
parent | 8c4ab3f0ee98a95d19dbfafced4a8b72e80170e4 [diff] |
Migrate 25 crates to monorepo am: 8c4ab3f0ee Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/cast/+/3219575 Change-Id: I742b0396df1cf091e62bf12082b7d083bee342b5 Signed-off-by: Automerger Merge Worker <[email protected]>
cast
Ergonomic, checked cast functions for primitive types
extern crate cast; // `u8` and `u16` are checked cast functions, use them to cast from any numeric // primitive to `u8`/`u16` respectively use cast::{u8, u16, Error}; // Infallible operations, like integer promotion, are equivalent to a normal // cast with `as` assert_eq!(u16(0u8), 0u16); // Everything else will return a `Result` depending on the success of the // operation assert_eq!(u8(0u16), Ok(0u8)); assert_eq!(u8(256u16), Err(Error::Overflow)); assert_eq!(u8(-1i8), Err(Error::Underflow)); assert_eq!(u8(1. / 0.), Err(Error::Infinite)); assert_eq!(u8(0. / 0.), Err(Error::NaN));
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.