EmptyBox, a way to safely move values in and out of Boxs without
reallocations
EmptyBox is similar to a statically checked Box<Option<T>>:
use EmptyBox;
// A box with a string!
let boxed = Boxnew;
// Oh no, we don't like that string.
let = take;
// Let's make an objectively superior string, and put it into the original
// box.
let superior = "Objectively superior string!".to_string;
// Now we have our superior string in the box!
let boxed = empty.put;
assert_eq!;
assert_eq!;
Creating an EmptyBox from a Box and then putting a T back into the
EmptyBox will avoid allocating a new Box, instead reusing whatever old
Box the T was EmptyBox::taken from.
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.