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