4 ms·
> Specify a unique reference? (`&T` is shared, `&mut T` is unique) shared T shared mut T > Specify a lifetime? (`&'a T` is a reference to T with lifetime `a`
by Aeolun 5y ago
> Specify a unique reference? (`&T` is shared, `&mut T` is unique)
shared T
shared mut T
> Specify a lifetime? (`&'a T` is a reference to T with lifetime `a`)
shared T lifetime a
> Specify a raw pointer? (`const T` and `mut T` are const/non-const raw pointers)
const point T
point mut T
> Specify that the argument is moved into the function? (just the raw type `T`)
T
- conradludgate 5y agoWhile this may be better in retrospect, it doesn't mean it's how Rust should have been. Rust was designed to replace C++, so using more C++ was probably the right call to get people to consider it more. I do disagree on the syntax for the references though. I prefer they be easier to type than the owned versions (eg &[u8] vs Vec<u8>) as this can promote the usual better choice (this is a weak argument, I acknowledge). I do wish that history had chosen a different symbol for references though. But there's only so much we can do now
- iamthemalto 5y agoInteresting idea, but honestly that seems too far in the other direction. A midpoint between the two ends that optimizes both brevity and readability is probably ideal.