Crates.io | boxing |
lib.rs | boxing |
version | 0.1.2 |
source | src |
created_at | 2023-06-05 20:21:55.222529 |
updated_at | 2023-06-06 18:14:22.78998 |
description | Easy-to-use, cross-platform implementations for NaN and ptr boxes |
homepage | |
repository | https://github.com/CraftSpider/boxing |
max_upload_size | |
id | 883307 |
size | 78,944 |
An easy-to-use, cross-platform library for pointer and NaN boxing data - storing other data values in the unused portions of a float or pointer.
For more detailed examples, see the nan
module documentation.
use boxing::nan::NanBox;
assert_eq!(core::mem::size_of::<NanBox<()>>(), core::mem::size_of::<f64>());
let a = NanBox::<()>::from_float(2.0);
let b = NanBox::<()>::from_inline(-1i32);
assert_eq!(a.clone().try_into_float(), Ok(2.0));
assert_eq!(b.clone().try_into_inline::<i32>(), Ok(-1i32));
assert!((a.into_float_unchecked() + b.into_float_unchecked()).is_nan());