commit | b7a0d8843704b6c500a679a99d5485bc44e21ead | [log] [tgz] |
---|---|---|
author | Matthew Maurer <mmaurer@google.com> | Tue May 31 16:45:51 2022 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Tue May 31 16:45:51 2022 +0000 |
tree | df70eb89530c510f9a45130a574c32151e93d822 | |
parent | d5fcc9aabd36be3a474596b2f7f51f6a080f5480 [diff] | |
parent | 1078cd2e5bb5bdf057ca99cf816d31e8d7dad9e7 [diff] |
Update TEST_MAPPING am: 5812e6f408 am: 1078cd2e5b Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/cast/+/2107370 Change-Id: I3318beb3430c762b6a8e37a74e3e7ba2c4461c74 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
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.