Hacker News new | past | comments | ask | show | jobs | submit login

Small correction: contrary to what the post claims this does not compile:

    fn main() {
        let s = String::from("hello");
        foo(s);
        println!("{}", s);
    }

    fn foo(le_string: String) -> String {
        println!("{}", le_string);
        le_string
    }
This does, which is probably what the author meant:

    fn main() {
        let s = String::from("hello");
        let s = foo(s);
        println!("{}", s);
    }

    fn foo(le_string: String) -> String {
        println!("{}", le_string);
        le_string
    }
Great post!



Indeed, thank you for catching it! I will make an update.

Thanks again!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: