tag | f75a8a5b45efb372f2a98c92bf3f01f5b6949801 | |
---|---|---|
tagger | The Android Open Source Project <initial-contribution@android.com> | Thu May 04 16:18:06 2023 -0700 |
object | f36a9af95bfe1fe4e2d1bdc02b985a19f2c270fe |
Platform Tools Release 34.0.1 (9680074)
commit | f36a9af95bfe1fe4e2d1bdc02b985a19f2c270fe | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Wed Feb 01 10:59:30 2023 +0000 |
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Wed Feb 01 10:59:30 2023 +0000 |
tree | 8a1df24ff4549f3ff836f4b7f89f4bbeff716fc4 | |
parent | 0e20876e0b6647e29987e921d9e601da4a78b000 [diff] | |
parent | 2a622be6b3b28eda0b906ccb6c1f626f107208b8 [diff] |
Snap for 9550355 from 2a622be6b3b28eda0b906ccb6c1f626f107208b8 to sdk-release Change-Id: I7533a2bebcfc632b60c6b65d897ab63508322a4f
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.