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
pubfnsqrt(n:u32) -> u32{letmut x;let next = move |x:u32| (x + n / x) >> 1;
x = next(1);loop{let xn = next(x);if x <= xn {return x;}
x = xn;}}
Note that next is called in two places, but it gets a warning that it's called just once:
$ cargo +nightly clippy -V
clippy 0.0.212 (5afdf8b 2018-10-14)
$ cargo +nightly clippy
Checking sqrt v0.1.0 (/tmp/sqrt)
warning: Closure called just once immediately after it was declared
--> src/lib.rs:5:5
|
5 | x = next(1);
| ^^^^^^^^^^^
|
= note: #[warn(clippy::redundant_closure_call)] on by default
= help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#redundant_closure_call
Finished dev [unoptimized + debuginfo] target(s) in 0.47s
If I move next to be declared first, the warning goes away.
The text was updated successfully, but these errors were encountered:
Note that
next
is called in two places, but it gets a warning that it's called just once:If I move
next
to be declared first, the warning goes away.The text was updated successfully, but these errors were encountered: