borrowme
The missing compositional borrowing for Rust.
This crate provides an attribute macro which helps you achieve compositional borrowing. Roughly this means that you can convert a struct which has lifetimes into ones which does not and vice versa.
See the #[borrowme] attribute for detailed documentation on
how the attribute works.
let text = Stringfrom;
let lang = Some;
let word = Word ;
let word2: OwnedWord = to_owned;
assert_eq!;
assert_eq!;
let word3: = borrow;
assert_eq!;
Rust comes with two sibling traits which both are responsible for converting
something to an owned and a borrowed variant: ToOwned and
Borrow.
These convert a type to a borrowed value to an owned one, let's think about it from a broader perspective: How to we convert a type which has lifetimes, to one which does not?
To this end this crate defines two similar traits: ToOwned and
[Borrow]. These traits serve a similar purpose to the traits in std but
are implemented differently. See their corresponding documentation for more
details.