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.


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

Search: