Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. use std::borrow::Cow;
  2.  
  3. struct Foo<'a>(Cow<'a, [u8]>);
  4. struct FooList<'a>(Vec<Foo<'a>>);
  5.  
  6. impl<'a> Clone for Foo<'a> {
  7. fn clone(&self) -> Foo<'static> {
  8. Foo(self.0.to_vec().into())
  9. }
  10. }
  11.  
  12. impl<'a> Clone for FooList<'a> {
  13. fn clone(&self) -> FooList<'static> {
  14. FooList(self.0.iter().map(|foo| {
  15. let vec = foo.0.clone().into_owned();
  16. Foo(vec.into())
  17. }).collect())
  18. }
  19. }
  20.  
  21. fn main() {
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement