3 ms·
> injecting `AsRef` everywhere adds a lot of visual clutter I agree! `fn foo<T: AsRef<str>>(s: T)` This is so difficult to read, one has to jump back and for
by Ciantic 6y ago
> injecting `AsRef` everywhere adds a lot of visual clutter
I agree!
`fn foo<T: AsRef<str>>(s: T)`
This is so difficult to read, one has to jump back and forth with eyes to make any sense of these. Why couldn't there be easier syntax for "AsReffing"? E.g.
`fn foo(s: @str)`
I invented @-sign there.
- stuhood 6y agoCan use `impl Trait` I think? ``` fn foo(s: impl AsRef<str>) ```
- steveklabnik 6y agoSyntax like @T was actually a type in ancient Rust. People really, really hated having even more sigils in the language, so we ended up removing them. There was also ~T.
- jcranmer 6y agoIIRC, one of the sigils was for reference counting, and there was to be another one for garbage-collected types? (I'm recalling the lunch conversations from when I sat in the room with all the Rust interns).
- steveklabnik 6y ago@T was supposed to be a GC'd type, but ended up being a refcounted type. It was removed before it actually turned into a GC'd type. ~T was Box<T>. However, one issue here was that they didn't compose in the same way as types today; ~str existed, for example, but was not the exact same as String in terms of memory layout. Conceptually they're the same thing though.
- mrlonglong 6y agoMassive turbofish! :-D