commit | cadc4315731c03427cdfcebdbf938bd7c7372f7c | [log] [tgz] |
---|---|---|
author | Joel Galenson <jgalenson@google.com> | Fri Aug 13 00:26:44 2021 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Fri Aug 13 00:26:44 2021 +0000 |
tree | f3beeb2524523fde5f9f105e35d9a499df91b27a | |
parent | cc8b649d21d417bcade31358f42d6de89985047e [diff] | |
parent | b7644ad73812e398f52e7c2d58c0a13fb83c6fe7 [diff] |
Upgrade rust/crates/cast to 0.2.7 am: 2d2f5bcda8 am: 0774bb4772 am: fc04201e56 am: af47986129 am: b7644ad738 Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/cast/+/1791027 Change-Id: I93897dfbdd252cac64028aee852b797baf18672f
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.