Crates.io | explicit_cast |
lib.rs | explicit_cast |
version | 1.0.0 |
source | src |
created_at | 2023-12-07 00:38:31.09947 |
updated_at | 2023-12-07 00:38:31.09947 |
description | A crate for explicit widening, truncating, and sign casting of primitive integers |
homepage | https://github.com/ultrabear/explicit_cast |
repository | https://github.com/ultrabear/explicit_cast |
max_upload_size | |
id | 1060562 |
size | 22,229 |
explicit_cast
A crate for explicitly widening, truncating, and sign casting integers.
This crate is very simple, but the functionality it provides is universal, as such, it is distributed under Apache-2.0 OR MIT
.
use explict_cast::prelude::*;
let my_value: u8 = u16::MAX.truncate();
let next: i16 = my_value.widen().sign_cast();
assert_eq!(next, 0xffi16);