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

It's not anything specific to arrays, it's just how type inference works. Here's another example:

    let mut x = HashMap::new();
    x.insert(1, 2);
Note that nowhere did we need to specify the concrete type of the HashMap; the compiler sees that you eventually insert numbers into the map so it uses that information to fill in the generic type parameters for the key and value.


Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

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

Search: