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

One neat thing Rust let you do is put underscores in number literals. It's great for readibility:

    0xFFFF_FFFF // easier to count than 8 Fs
And you can use that with type suffixes:

    let a = 255_u8;
Although in that case, you'd probably either omit u8 entirely, letting the compiler infer the type of 'a' from usage, or use a colon to give it ane explicit type.

Type suffixes are especially useful for arguments to generic functions:

    write_le(12_u32);
    write_le(255_u8);


You can do the same thing with C#, which is great for groupings, e.g. "2000000" becomes "2_000_000".

As a rust noob, I didn't realise rust supported the same syntax, or that you could use it to separate the type from the value (which in rust's case, I find really helps readability).


C# 7 (2017) and higher also allows underscores in number literals.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: