3 ms·
Yes, it’s a type signature. It looks typical of Rust internals, but it would be very verbose for user code. You’re not wrong to find it illegible; apart from t
by dethinking 7y ago
Yes, it’s a type signature. It looks typical of Rust internals, but it would be very verbose for user code.
You’re not wrong to find it illegible; apart from the syntax, that phrase invokes the concepts of lifetimes, mutability, borrowing, and traits, none of which have straightforward semantic analogues in other common languages.
But FWIW they’re primitive concepts in Rust. A typical Rust user wouldn’t read or write code that looks like that very much, but they would know what it means, if that makes any sense.
Edit: Seeing sibling comments about whether this snippet actually parses, I guess I should amend this to say that a typical Rust user has an idea of what it’s supposed to mean :)
- hollerith 7y agoSignature for the type of which identifier? "for"?
- dethinking 7y agoI think I originally had “piece of a type signature”, but I didn’t actually want to figure out which piece, so I fudged it. The point is well taken, I oughtn’t pretend I have a Rust parser in my head :)
- dodobirdlord 7y agoFirst of all, it’s not actually valid syntax because I believe Rust doesn’t have negative trait bounds. But it’s a trait bound, so it’s (part) of a type signature. The type here is generic over both lifetimes and types (I think). My vague understanding is that for<‘a, T: ?Sized> means “in any lifetime, any type that is a member of ‘?Sized’”. And then the rest of the signature goes on to say (in made-up syntax) “does not implement DerefMut”. I think ?Sized means “size not known at compile time.”