]> git.proxmox.com Git - rustc.git/blob - src/test/ui/nll/issue-43058.rs
Update upstream source from tag 'upstream/1.31.0_beta.4+dfsg1'
[rustc.git] / src / test / ui / nll / issue-43058.rs
1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // compile-pass
12
13 #![feature(nll)]
14
15 use std::borrow::Cow;
16
17 #[derive(Clone, Debug)]
18 struct S<'a> {
19 name: Cow<'a, str>
20 }
21
22 #[derive(Clone, Debug)]
23 struct T<'a> {
24 s: Cow<'a, [S<'a>]>
25 }
26
27 fn main() {
28 let s1 = [S { name: Cow::Borrowed("Test1") }, S { name: Cow::Borrowed("Test2") }];
29 let b1 = T { s: Cow::Borrowed(&s1) };
30 let s2 = [S { name: Cow::Borrowed("Test3") }, S { name: Cow::Borrowed("Test4") }];
31 let b2 = T { s: Cow::Borrowed(&s2) };
32
33 let mut v = Vec::new();
34 v.push(b1);
35 v.push(b2);
36
37 println!("{:?}", v);
38 }