Crates.io | evobox |
lib.rs | evobox |
version | 0.1.1 |
source | src |
created_at | 2019-11-28 23:44:04.453645 |
updated_at | 2019-11-28 23:53:11.942949 |
description | A pointer type which allows for safe transformations of its content without reallocation. |
homepage | |
repository | https://github.com/lcnr/evobox |
max_upload_size | |
id | 185175 |
size | 18,122 |
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.
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);