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
Playing around with the following code, I accidentally left an map() call on the Option type (originally, the closure was dereferencing the parameter, or calling clone() on it, something like that). But I noticed that Clippy doesn't suggests that using map() like this is unnecessary:
fnfib(n:usize,memo:&mut[Option<usize>]) -> usize{
memo[n].map(|v| v).unwrap_or_else(|| {let result = {if n > 1{fib(n - 1, memo) + fib(n - 2, memo)}else{1}};
memo[n] = Some(result);
result
})}fnmain(){let number = 46;letmut memo:Vec<Option<usize>> = vec![None; number + 1];println!("{}", fib(number,&mut memo));}
And if I turn on "pedantic" mode, the suggestion I get is to use map_or_else.
Playing around with the following code, I accidentally left an
map()
call on theOption
type (originally, the closure was dereferencing the parameter, or callingclone()
on it, something like that). But I noticed that Clippy doesn't suggests that usingmap()
like this is unnecessary:And if I turn on "pedantic" mode, the suggestion I get is to use
map_or_else
.Play link
The text was updated successfully, but these errors were encountered: