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

Again, what if there is no static declaration?

    impl Foo {
        // static
        fn foo() {}
    }
Why would I need to use self to tell the compiler about an instance method? Surely the Rust compiler is smart enough to detect this case and complain if the call site is ambiguous.



> Again, what if there is no static declaration?

So your suggestion is to remove static methods from the language?

> Why would I need to use self to tell the compiler about an instance method? Surely the Rust compiler is smart enough to detect this case and complain if the call site is ambiguous.

Detect what case? There is a dozen and eventually an infinite number of potential instance call ABIs.

And the Rust compiler is generally very much on the “refuse to guess” side of the fence (hence no global type inference), so you have to tell it what it should expect, `self`, `&mut self`, and `&self` have rather different requirements, impacts, and capabilities to say nothing of the rest.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: