Guest User

Untitled

a guest
Oct 16th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. use std::borrow::Cow;
  2.  
  3. struct Foo<'a, T: 'a> where [T]: std::borrow::ToOwned {
  4. inner: Cow<'a, [T]>,
  5. }
  6.  
  7. impl <'a, T>Foo<'a, T> where [T]: std::borrow::ToOwned {
  8. pub fn new<I: Into<Cow<'a, [T]>>>(inner: I) -> Self {
  9. Foo {
  10. inner: inner.into(),
  11. }
  12. }
  13. }
  14.  
  15. fn main() {
  16. let a = "a".to_string();
  17. let b = "b".to_string();
  18. let c = "c".to_string();
  19. let d = "d".to_string();
  20.  
  21. let exp = [a, b];
  22. let _a = Foo::new(&exp[..]);
  23. let _b = Foo::new(vec![c, d]);
  24. }
Add Comment
Please, Sign In to add comment