]> git.proxmox.com Git - rustc.git/blame - src/test/ui/traits/with-bounds-default.rs
Merge tag 'debian/1.52.1+dfsg1-1_exp2' into proxmox/buster
[rustc.git] / src / test / ui / traits / with-bounds-default.rs
CommitLineData
b7449926 1// run-pass
970d7e83
LB
2
3pub trait Clone2 {
62682a34 4 /// Returns a copy of the value. The contents of boxes
970d7e83
LB
5 /// are copied to maintain uniqueness, while the contents of
6 /// managed pointers are not copied.
7 fn clone(&self) -> Self;
8}
9
970d7e83
LB
10trait Getter<T: Clone> {
11 fn do_get(&self) -> T;
12
13 fn do_get2(&self) -> (T, T) {
14 let x = self.do_get();
15 (x.clone(), x.clone())
16 }
17
18}
19
c34b1796
AL
20impl Getter<isize> for isize {
21 fn do_get(&self) -> isize { *self }
970d7e83
LB
22}
23
24impl<T: Clone> Getter<T> for Option<T> {
1a4d82fc 25 fn do_get(&self) -> T { self.as_ref().unwrap().clone() }
970d7e83
LB
26}
27
28
1a4d82fc 29pub fn main() {
970d7e83 30 assert_eq!(3.do_get2(), (3, 3));
1a4d82fc 31 assert_eq!(Some("hi".to_string()).do_get2(), ("hi".to_string(), "hi".to_string()));
970d7e83 32}