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
This is ok for non-default values, but I propose we suggest unwrap_or_default instead for default values of primitive types, which all happen to be 0, and false for bools.
So instead we'd write:
num.unwrap_or_default();
Our syntax is longer, but it'd hard to come up with a case where default value has more characters than keyword "default" itself, which is 7 chars long. If we have an unwrap_or_default method, it makes sense to use it.
Comments please.
Version
No response
Additional Labels
No response
The text was updated successfully, but these errors were encountered:
If we have an unwrap_or_default method, it makes sense to use it.
It only makes sense if it makes the intent clearer. I don't see that for most default values, .unwrap_or(false), .unwrap_or(0), .unwrap_or(None) all seem clearer (and shorter!) than .unwrap_or_default().
Description
Currently this is used:
This is ok for non-default values, but I propose we suggest
unwrap_or_default
instead for default values of primitive types, which all happen to be 0, andfalse
for bools.So instead we'd write:
Our syntax is longer, but it'd hard to come up with a case where default value has more characters than keyword "default" itself, which is 7 chars long. If we have an
unwrap_or_default
method, it makes sense to use it.Comments please.
Version
No response
Additional Labels
No response
The text was updated successfully, but these errors were encountered: