3 ms·
"returns" and "is of type" are different concepts, so having different syntax for them makes sense. - In your first example, foo is of type "Bar" - In your se
by jomohke 9y ago
"returns" and "is of type" are different concepts, so having different syntax for them makes sense.
- In your first example, foo is of type "Bar"
- In your second, foo is of type "function that returns Bar".
ie, if you stored your foos in separate variables they would be:
let my_var: Bar = ...
vs
let my_function: fn() -> Bar = ...
If they were to change it to your suggestion the latter would be either awkward (multiple colons?) or inconsistent (different syntax for types and declarations).