News for hackers. Stuff that matters.
Re:Making Rust a Better Fit for Cheri and Other Platforms by pwdisswordfish9 on Thursday April 14, 2022 @05:07AM (#31024708)
What’s wrong with .try_into::<usize>().unwrap()?
Re:Making Rust a Better Fit for Cheri and Other Platforms by masklinn on Thursday April 14, 2022 @06:34AM (#31025114)
.into() will work for u8 and u16, as rust assumes >= 16b pointers.
Re:Making Rust a Better Fit for Cheri and Other Platforms by est31 on Thursday April 14, 2022 @08:21AM (#31025906)
Which totally makes sense. u8 means 256 bytes of addressable memory. You might design chips with such limited memory, but maybe high level (read non assembly) languages are not the right tool for targetting them.
Re:Making Rust a Better Fit for Cheri and Other Platforms by ekhjarta on Thursday April 14, 2022 @05:14AM (#31024746)
It fails at runtime and not at compile time and it only fails if the value is out of range, so you have to test with large enough values to trigger the assertion during testing.

We want to be able to index with integer types that are smaller than or has the same size as usize, but not with integer types that are larger than usize. And we want those checks at compile time.

Re:Making Rust a Better Fit for Cheri and Other Platforms by dgb23 on Thursday April 14, 2022 @05:32AM (#31024811)
Unwrap isn’t an evil thing to avoid completely. The type system cannot understand all invariants, but you can, and you can make sure they are correctly implemented.
Re:Making Rust a Better Fit for Cheri and Other Platforms by edflsafoiewq on Thursday April 14, 2022 @08:04AM (#31025752)
It's hideous.