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;
10 trait Getter<T: Clone> {
11 fn do_get(&self) -> T;
13 fn do_get2(&self) -> (T, T) {
14 let x = self.do_get();
15 (x.clone(), x.clone())
20 impl Getter<isize> for isize {
21 fn do_get(&self) -> isize { *self }
24 impl<T: Clone> Getter<T> for Option<T> {
25 fn do_get(&self) -> T { self.as_ref().unwrap().clone() }
30 assert_eq!(3.do_get2(), (3, 3));
31 assert_eq!(Some("hi".to_string()).do_get2(), ("hi".to_string(), "hi".to_string()));