tag | 946ce4cae2e0d7f3e2f758d5fa7cd84532bad07d | |
---|---|---|
tagger | The Android Open Source Project <initial-contribution@android.com> | Wed Jun 09 15:38:22 2021 -0700 |
object | 8ef0327c75ed3602ba53cc098ac1295a3c48b550 |
Android S Beta 2 (SPB2.210513.007)
commit | 8ef0327c75ed3602ba53cc098ac1295a3c48b550 | [log] [tgz] |
---|---|---|
author | Bob Badour <bbadour@google.com> | Wed Mar 17 13:03:31 2021 -0700 |
committer | Bob Badour <bbadour@google.com> | Wed Mar 17 13:03:31 2021 -0700 |
tree | 9348b0e0d4617d9e3bf58aff6a2a2d0db3e56b29 | |
parent | 0fa02c0ba5c184fdbc213e700d10ce034a3922b8 [diff] |
[LSC] Add LOCAL_LICENSE_KINDS to external/rust/crates/cast Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-MIT to: Android.bp Bug: 68860345 Bug: 151177513 Bug: 151953481 Test: m all Exempt-From-Owner-Approval: janitorial work Change-Id: Iff156e45679075bdde7074d68bb100342e8782ce
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.