"The simplest and most common use of generics is for type parameters"
Are there other use cases? 
-
Show this thread
-
-
I suspect that bounding generics by traits is simpler, as traits can't extend other traits. Can they? Is there subtyping in rust beyond `!`?
3 replies 0 retweets 2 likesShow this thread -
If a struct is empty, `S{}` and `S` are equivalent. I find `S` confusing, as it's the name of the type, but used as an expression.
1 reply 0 retweets 2 likesShow this thread -
This is a very elegant way of expressing a pretty complex bound impl<T> PrintInOption for T where Option<T>: Debug { This also works with `T: Debug`, but it's a good example anyway.
2 replies 0 retweets 3 likesShow this thread -
There's a section called `newtype` idiom, that doesn't mention `newtype` at all. IIRC that's a keyword for creating opaque types in Haskell. In rust, those are just struct tuples.
2 replies 0 retweets 3 likesShow this thread -
How can this even work? Isn't it comparing two references? Aren't references ~= memory addresses?pic.twitter.com/DFtOmYJID7
3 replies 0 retweets 2 likesShow this thread -
I'm not convinced that associated types improve readability. They are less explicit. I have the feeling that Rust's syntax design is somewhat inconsistent, sometimes optimized for conciseness (e.g `!`, or these types), and sometimes for clarity `where`. I prefer the latter.
3 replies 0 retweets 1 likeShow this thread -
I'd love to know how generics are compiled, this book doesn't mention it. Are they reified? BTW, if you are reading this because you are also coming from JS, not knowing what that means is totally fine.
3 replies 0 retweets 1 likeShow this thread -
What's the deal with PhantomData?
4 replies 1 retweet 4 likesShow this thread
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.


