Skip to content

[Mutable borrows] Error in tutorial #27

Description

@iyernaveenr

Hello,

In the "Mutable borrows" tutorial:
http://intorust.com/tutorial/mutable-borrows/
https://www.youtube.com/watch?v=pd7PJ6q4I3M&t=354s

The issue discussed ~06:15 does not happen. Please find all the details below:

$ cat main.rs
fn main() {
    let mut name = format!("fellow Rustaceans");
    let r = &mut name;
    helper(r);
    helper(r);
    println!("{}", name);
}

fn helper(name: &mut String) {
	name.push_str("foo");
}
$ rustc --edition 2015 main.rs
$ echo $?
0
$ ./main
fellow Rustaceansfoofoo
$ echo $?
0
$ rustc --edition 2021 main.rs
$ echo $?
0
$ ./main
fellow Rustaceansfoofoo
$ echo $?
0
$ rustc --version
rustc 1.84.0-nightly (32b17d56e 2024-10-28)
$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.4 LTS
Release:	22.04
Codename:	jammy
$ uname -m
x86_64
$ uname -r
6.5.0-44-generic
$ 

Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions