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
For programmer point of view there is no visible reason that operands of "non-regular" versions of arithmetic operators (saturating, overflowing, ...) can't be inferred in some situations when "regular" do it.
fnmain(){letmut sum = 0;
sum = sum + 1_usize;// Okletmut sum = 0;
sum = sum.saturating_add(1_usize);// Error}
Compiling playground v0.0.1 (/playground)
error[E0689]: can't call method `saturating_add` on ambiguous numeric type `{integer}`
--> src/main.rs:5:15
|
5 | sum = sum.saturating_add(1_usize); // Error
| ^^^^^^^^^^^^^^
|
help: you must specify a type for this binding, like `i32`
|
4 | let mut sum: i32 = 0;
| ^^^^^^^^^^^^
It could be nice if saturating version of sum can be inferred to usize too.
The text was updated successfully, but these errors were encountered:
For programmer point of view there is no visible reason that operands of "non-regular" versions of arithmetic operators (saturating, overflowing, ...) can't be inferred in some situations when "regular" do it.
(Playground)
Errors:
It could be nice if saturating version of
sum
can be inferred tousize
too.The text was updated successfully, but these errors were encountered: