Guest User

Untitled

a guest
May 26th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. trait Tr {
  2. fn trim_indent(&self) -> &Self;
  3. }
  4.  
  5. impl Tr for str {
  6. fn trim_indent(&self) -> &Self {
  7. &self[..1] // some transformation here
  8. }
  9. }
  10.  
  11. trait Tr1 {
  12. fn trim_indent(self) -> Self;
  13. }
  14.  
  15. impl<'a> Tr1 for &'a str {
  16. fn trim_indent(self) -> Self {
  17. &self[..1] // some transformation here
  18. }
  19. }
  20.  
  21.  
  22. fn main() {
  23. let _: Box<Tr> = unimplemented!();
  24. let _: Box<Tr1> = unimplemented!();
  25. let func = <str as Tr>::trim_indent;
  26. let func = <&str as Tr1>::trim_indent;
  27. }
Add Comment
Please, Sign In to add comment