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
E.g., if matching a String with a @ "foo", should a have type String, &str, or &String?
One 'nice to have' is for a (an unconstrained variable) and a @ ... to have the same type.
Note that &String can always be coerced to &str, so in most contexts is strictly more general. I think that if we follow the 'match ergonomics' binding mode rules, then that decides if the variable should be used by move or ref (i.e., if a should have type String or &String or &mut String). Note that if we're matching Ptr<String> then we can only bind by move if Ptr: DerefMove, since DerefMove does not yet exist, this is a type error unless Ptr is Box.
The text was updated successfully, but these errors were encountered:
Previous discussion, Zulip
E.g., if matching a
String
witha @ "foo"
, shoulda
have typeString
,&str
, or&String
?One 'nice to have' is for
a
(an unconstrained variable) anda @ ...
to have the same type.Note that
&String
can always be coerced to&str
, so in most contexts is strictly more general. I think that if we follow the 'match ergonomics' binding mode rules, then that decides if the variable should be used by move or ref (i.e., ifa
should have typeString
or&String
or&mut String
). Note that if we're matchingPtr<String>
then we can only bind by move ifPtr: DerefMove
, sinceDerefMove
does not yet exist, this is a type error unlessPtr
isBox
.The text was updated successfully, but these errors were encountered: