Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::borrow::Cow;
- struct Foo<'a>(Cow<'a, [u8]>);
- struct FooList<'a>(Vec<Foo<'a>>);
- impl<'a> std::borrow::ToOwned for Foo<'a> {
- type Owned = Foo<'static>;
- fn to_owned(&self) -> Foo<'static> {
- Foo(self.0.to_vec().into())
- }
- }
- impl<'a> Clone for FooList<'a> {
- fn clone(&self) -> FooList<'static> {
- FooList(self.0.iter().map(|foo| {
- let vec = foo.0.clone().into_owned();
- Foo(vec.into())
- }).collect())
- }
- }
- fn main() {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement