Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

This change improves consistency between implementations and modules. `impl MyType { … }` is now just like `mod my_module { … }`, except that you can define methods inside `impl` declarations by including a self parameter.

For example:

    struct MyType { … }
    impl MyType { pub fn foo() { … } }
    mod my_module { pub fn foo() { … } }
    fn main() {
        MyType::foo(); // works
        my_module::foo(); // works too
    }


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

Search: