Guest User

Untitled

a guest
May 23rd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. struct S {
  2. a: String,
  3. }
  4.  
  5. fn library_fn(s: &String) -> String {
  6. let mut r = String::from("foo");
  7. r.push_str(&s[..]);
  8. r
  9. }
  10.  
  11. impl S {
  12. fn change_a(&mut self) {
  13. self.a = library_fn(&self.a);
  14. }
  15. }
  16.  
  17. fn main () {
  18. let mut s = S { a: String::from("bar") };
  19. s.change_a();
  20. println!("{:?}",s.a);
  21. }
Add Comment
Please, Sign In to add comment