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

Array filling shares syntax with array typing and array declaration:

    [0; 10] // ten-element array filled with zeros
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] // equivalent array with ten zeroes typed out
    [i32; 10] // type of ten-element i32 array
Because the "filling" syntax is optional, it makes sense to place it after the fill value. The array typing syntax follows. Essentially you specify the value and say "copy this X times" (it only works with types that implement Copy IIRC)

https://play.rust-lang.org/?version=stable&mode=debug&editio...



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

Search: