]> git.lizzy.rs Git - rust.git/blob - src/test/ui/traits/with-bounds-default.rs
:arrow_up: rust-analyzer
[rust.git] / src / test / ui / traits / with-bounds-default.rs
1 // run-pass
2
3 pub trait Clone2 {
4     /// Returns a copy of the value. The contents of boxes
5     /// are copied to maintain uniqueness, while the contents of
6     /// managed pointers are not copied.
7     fn clone(&self) -> Self;
8 }
9
10 trait 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
20 impl Getter<isize> for isize {
21     fn do_get(&self) -> isize { *self }
22 }
23
24 impl<T: Clone> Getter<T> for Option<T> {
25     fn do_get(&self) -> T { self.as_ref().unwrap().clone() }
26 }
27
28
29 pub fn main() {
30     assert_eq!(3.do_get2(), (3, 3));
31     assert_eq!(Some("hi".to_string()).do_get2(), ("hi".to_string(), "hi".to_string()));
32 }