#heap #box #transform #map

no-std evobox

A pointer type which allows for safe transformations of its content without reallocation

2 releases

0.1.1 Nov 28, 2019
0.1.0 Nov 28, 2019

#675 in Memory management

MIT license

17KB
257 lines

Evobox

A pointer type which allows for safe transformations of its content without reallocation. This crate does not depend on the standard library, and can be used in #![no_std] contexts. It does however require the alloc crate.

Examples

use evobox::{EvolveBox, L};

let s: EvolveBox<L<&str, L<String, L<u32>>>> = EvolveBox::new("7");
let owned = s.evolve(|v| v.to_string());
assert_eq!(owned.as_str(), "7");

let seven = owned.try_evolve(|s| s.parse()).expect("invalid integer");
assert_eq!(*seven, 7);

lib.rs:

A pointer type which allows for safe transformations of its content without reallocation. This crate does not depend on the standard library, and can be used in #![no_std] contexts. It does however require the alloc crate.

For more details look at the documentation of EvolveBox.

No runtime deps