4 ms·
This is a very nice article! And a very nicely designed blog. I’ve run into almost all of these issues myself. Only in Rust have I had to respond to someone’s P
by hardwaregeek 4y ago
This is a very nice article! And a very nicely designed blog. I’ve run into almost all of these issues myself. Only in Rust have I had to respond to someone’s PR feedback with “yes, that would be better but the compiler won’t let me for xyz reasons”.
I do wonder if someone could design a language with a little more built in logic that would be able to know that an Arc won’t be moved, or that can understand String can be matched to a str, if that could function as the often requested “higher level Rust”
- swsieber 4y agoThere are a few crates that abstract the unsafe setup you need for a self referential struct, but I'm not sure which or their status. And they might employ "Pin" for their abstraction, I'm not sure. Pin is basically a wrapper type to keep an object from being moved. The interesting thing is that Pin doesn't receive special compiler treatment for its implementation. It's implemented in normal rust (IIRC).
- estebank 4y ago> or that can understand String can be matched to a str That's called "deref patterns" and it's been made to work on nightly only for String for now, but 1) the implementation is currently a huge hack, 2) development stalled over the holidays but there's multiple interested parties to see this implemented and stabilized and 3) the idea is to make these "just work" (without any extra sigils or keywords) for specific Deref impls, maybe with a new marker trait DerefPure, which might or might not be available for end users to (similar to trait Try). DerefMut is IIRC still an open question.
- dontlaugh 4y agoThat language is probably Swift.