Uses new Rust 2021
|0.1.1||Nov 20, 2022|
|0.1.0||Nov 20, 2022|
#612 in Rust patterns
61 downloads per month
Clone-on-write smart pointer similar to Cow, but with relaxed trait constraints. Crate is totally
use laxcow::LaxCow; let lc = LaxCow::Borrowed("foobar"); let lc2 = lc.clone(); assert_eq!(lc2, LaxCow::Borrowed("foobar")); let owned = lc.into_owned(); assert_eq!(owned, "foobar".to_owned());
Usage not possible with
use laxcow::LaxCow; struct Foo; // We don't care about the owned type as it is not used. let laxcow = LaxCow::<_, ()>::Borrowed(&Foo);
Cow definition by wrapping
This example shows the difference between
Cow. It makes
Cow a struct, but only works here as an example.
use laxcow::LaxCow; struct Cow<'a, T: ?Sized + ToOwned>(LaxCow::<'a, T, <T as ToOwned>::Owned>);
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.
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.