Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[derive(Debug)]
- struct Heck<'a> {
- s: &'a mut String,
- }
- fn main() {
- let mut string = String::from("hey");
- let heck = Heck { s: &mut string };
- println!("{:?}", heck);
- heck.s.push('a');
- println!("{:?}", heck);
- // cannot borrow `*heck.s` as mutable, as it is behind a `&` reference
- // shared(&heck);
- // println!("{:?}", heck);
- }
- fn shared(heck: &Heck) {
- heck.s.push('a');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement