You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A unit-like struct is a struct without any fields, defined by leaving off the list of fields entirely. Such a struct implicitly defines a constant of its type with the same name. For example:
structCookie;let c = [Cookie,Cookie{},Cookie,Cookie{}];
is equivalent to
structCookie{}constCookie:Cookie = Cookie{};let c = [Cookie,Cookie{},Cookie,Cookie{}];
Which seems to imply that a curly-brace struct / struct struct definition with no fields a named constant of the same name is exactly the same thing as a unit struct definiton. However, this is not true when it comes to patterns: Cookie can be used as a pattern with the first declaration, but not with the second.
The text was updated successfully, but these errors were encountered:
From https://doc.rust-lang.org/reference/items/structs.html:
Which seems to imply that a curly-brace struct / struct struct definition with no fields a named constant of the same name is exactly the same thing as a unit struct definiton. However, this is not true when it comes to patterns:
Cookie
can be used as a pattern with the first declaration, but not with the second.The text was updated successfully, but these errors were encountered: