r/rust•
richhyd

Rust 2019 - Incremental Improvements

Im going to write a short post about all the small (ish) improvements that would make my rust experience even better. It's quite a selfish list, bit then others can make their own posts.

  1. Never type - it would really help me express intent sometimes. I think there is some work to do still, but hopefully the fact that the feature is simple will bound the amount of work & design required. Also we get TryFrom/Into for free.
  2. Const generics - Would really help in the embedded space I think - and also clearer code. I can just about make a wrapper type for my array, but it's a lot of work! It would also be awesome to see n-dimension stack-allocated matrices.
  3. Embedded code gen - having more solid embedded targets would be awesome. This is probably llvm work rather than rust work, although making more targets tier-1 would help embedded with reliability.

Stretch goals (not so incremental)

  1. Generic associated types - I'm not sure what the state is of these at the moment, but I know that there are no type systems with lifetimes and HKTs so this is a theoretically challenging goal.

Posted Dec 9, 2018, 8:56 PM UTC

227
cjstevenson1•

I mentioned it in another thread, but to summarize GAT is blocked on Chalk being finished. Chalk is the refactoring trait system project.

I'm thinking getting Chalk done will un-block many improvements, but go through along stabilization process.

1
dnaq•

I’d add read-write lifetimes to your list. I’ve written some code that would have been really nice if it could take a &mut self and return a read-only reference to some inner field without “locking” the lifetime of self.

0†
thiezrust•

You still wouldn't me able to call methods requiring &mut on a partially borrowed struct, because this "locks" the entire struct rather than just the fields that are being used. So what would be the benefit of this feature?

5
dnaq•

You’re probably right. Saw a blog post discussing this issue a while back and thought it’d map well against my use-case, but I think I might be wrong.

3
Saefroch•

This post? If not, probably one of the other posts on this (Niko's) blog.

3
HeroesGraverust · ecs-rs•

You could call `&self` methods. It's not a use case that comes up often but when it does happen it's really annoying to work around.

1
Holy_City•

Somewhat related, but allowing custom return types from Deref and DerefMut would help crate authors write APIs that could mitigate this (like RAII patterns around Arc<Mutex<T>>, property listeners, etc)

4