3 ms·
Do you feel that just because the inner value is named, rather than unnamed, it’s no longer a new type? Trying to figure out what line is crossed here.
by steveklabnik 6y ago
Do you feel that just because the inner value is named, rather than unnamed, it’s no longer a new type? Trying to figure out what line is crossed here.
- chrisoverzero 6y agoI'm going by the Rust documentation: https://doc.rust-lang.org/stable/rust-by-example/generics/new_types.html https://doc.rust-lang.org/stable/rust-by-example/generics/ne... (I was going to be cheeky here, but Git history shows you didn't write any of this part.)
- steveklabnik 6y agoHehe yeah, I mean, I am not 100% sure myself, which is why I asked. There's no real difference between a 1-tuple struct and the regular struct, other than the name. So to me, it feels like either are both newtypes. But, I guess I could see some sort of argument the other way too.
- lexi-lambda 6y agoIn Haskell, a newtype can be a single-field record with a named field, so from a Haskell perspective, I would definitely consider both of them “newtypes.”