File tree 1 file changed +8
-6
lines changed
src/doc/unstable-book/src/language-features
1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -17,15 +17,17 @@ when they'd need to do the same thing for every type anyway).
17
17
``` rust
18
18
#![feature(marker_trait_attr)]
19
19
20
- use std :: fmt :: { Debug , Display };
20
+ #[marker] trait CheapToClone : Clone {}
21
21
22
- #[marker] trait MyMarker {}
22
+ impl < T : Copy > CheapToClone for T {}
23
23
24
- impl <T : Debug > MyMarker for T {}
25
- impl <T : Display > MyMarker for T {}
24
+ // These could potentally overlap with the blanket implementation above,
25
+ // so are only allowed because CheapToClone is a marker trait.
26
+ impl <T : CheapToClone , U : CheapToClone > CheapToClone for (T , U ) {}
27
+ impl <T : CheapToClone > CheapToClone for std :: ops :: Range <T > {}
26
28
27
- fn foo <T : MyMarker >(t : T ) -> T {
28
- t
29
+ fn cheap_clone <T : CheapToClone >(t : T ) -> T {
30
+ t . clone ()
29
31
}
30
32
```
31
33
You can’t perform that action at this time.
0 commit comments