Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upSyntax for the unit constraint? #5
Comments
Centril
added
question
syntax
labels
Apr 6, 2018
This comment has been minimized.
This comment has been minimized.
comex
commented
Apr 6, 2018
This comment has been minimized.
This comment has been minimized.
|
Oh wow; Tho that is on the RHS instead of LHS. |
This comment has been minimized.
This comment has been minimized.
kennytm
commented
Apr 6, 2018
|
Use |
This comment has been minimized.
This comment has been minimized.
|
@kennytm hmm... should it not be "if you need something empty" ? |
This comment has been minimized.
This comment has been minimized.
kennytm
commented
Apr 6, 2018
|
@Centril I mean if |
This comment has been minimized.
This comment has been minimized.
|
@kennytm Right; Nicely spotted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Centril commentedApr 6, 2018
In the following example:
We have used
()as the "unit trait", that is, a "trait" that adds no constraints.This takes the approach in Haskell where we have the unit type
(), the unit value()(of type()), and the unit constraint().In Rust like Haskell, we do use
()for the unit type and()for the unit value, but we understandably have no unit constraint.Is this syntax legible in the sense that we understand that
Extra = ()means thatby default, and if nothing else is passed, the type alias becomes
Box<dyn Foo>?If not, what is a better syntax?