Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::borrow::Cow;
- struct Foo<'a, T: 'a> where [T]: std::borrow::ToOwned {
- inner: Cow<'a, [T]>,
- }
- impl <'a, T>Foo<'a, T> where [T]: std::borrow::ToOwned {
- pub fn new<I: Into<Cow<'a, [T]>>>(inner: I) -> Self {
- Foo {
- inner: inner.into(),
- }
- }
- }
- fn main() {
- let a = "a".to_string();
- let b = "b".to_string();
- let c = "c".to_string();
- let d = "d".to_string();
- let exp = [a, b];
- let _a = Foo::new(&exp[..]);
- let _b = Foo::new(vec![c, d]);
- }
Add Comment
Please, Sign In to add comment