Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct S {
- a: String,
- }
- fn library_fn(s: &String) -> String {
- let mut r = String::from("foo");
- r.push_str(&s[..]);
- r
- }
- impl S {
- fn change_a(&mut self) {
- self.a = library_fn(&self.a);
- }
- }
- fn main () {
- let mut s = S { a: String::from("bar") };
- s.change_a();
- println!("{:?}",s.a);
- }
Add Comment
Please, Sign In to add comment