News for hackers. Stuff that matters.
Re:Rust 1.50 by brundolf on Thursday February 11, 2021 @01:29PM (#26105294)
Wow, I did not know about those!

I'm surprised how little a Google search turns up for them; the best I found was a mention (but no description or examples) in docs.rs: https://docs.rs/rustc-ap-syntax_pos/634.0.0/rustc_ap_syntax_...

Do these enforce against out-of-bounds values by panicking, the way arrays do? Or are they unsafe?

Re:Rust 1.50 by jleahy on Thursday February 11, 2021 @02:55PM (#26106297)
They're not only unsafe, but as far as I'm aware they're a compiler implementation detail that isn't really supposed to be used in user code (along with rustc_nonnull_optimization_guaranteed). It's actually how NonZero is implemented.

See https://github.com/rust-lang/rust/blob/master/library/core/s...

Re:Rust 1.50 by brundolf on Thursday February 11, 2021 @03:01PM (#26106358)
Ah, that explains things
Re:Rust 1.50 by tmzt on Thursday February 11, 2021 @04:47PM (#26107797)
It would be nice to have a #[range(a..b)] version of this that could be standardized.
Re:Rust 1.50 by volta83 on Friday February 12, 2021 @03:13AM (#26111641)
> Or are they unsafe?

They are unsafe. The safe API of your type must prevent constructing invalid values.