File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed 
src/doc/unstable-book/src/language-features Expand file tree Collapse file tree 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).
1717``` rust 
1818#![feature(marker_trait_attr)]
1919
20- use   std :: fmt :: { Debug ,  Display }; 
20+ #[marker]  trait   CheapToClone :   Clone  {} 
2121
22- #[marker]  trait   MyMarker  {}
22+ impl < T :   Copy >  CheapToClone   for   T  {}
2323
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 > {}
2628
27- fn  foo <T :  MyMarker >(t :  T ) ->  T  {
28-     t 
29+ fn  cheap_clone <T :  CheapToClone >(t :  T ) ->  T  {
30+     t . clone () 
2931}
3032``` 
3133
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments