https://github.com/craftspider/boxing
https://github.com/craftspider/boxing
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/craftspider/boxing
- Owner: CraftSpider
- Created: 2023-06-02T14:42:59.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-06-08T23:44:34.000Z (about 3 years ago)
- Last Synced: 2025-04-11T10:37:49.880Z (about 1 year ago)
- Language: Rust
- Size: 73.2 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Boxing
[](https://crates.io/crates/boxing)
[](https://docs.rs/boxing)
[](./LICENSE-APACHE)
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.
## Examples
For more detailed examples, see the `nan` module documentation.
```rust
use boxing::nan::NanBox;
assert_eq!(core::mem::size_of::>(), core::mem::size_of::());
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::(), Ok(-1i32));
assert!((a.into_float_unchecked() + b.into_float_unchecked()).is_nan());
```