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
pub fn sounder<'a>(div: u32, msg: &'a str) -> impl Fn(u32) -> Option<&'a str>
{
move |n: u32|{
if n % div != 0 {
return None;
};
Some(msg)
}
}
Clippy is telling me that
warning: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
--> src/lib.rs:1:1
|
1 | / pub fn sounder<'a>(div: u32, msg: &'a str) -> impl Fn(u32) -> Option<&'a str>
2 | | {
3 | | move |n: u32|{
4 | | if n % div != 0 {
... |
9 | | }
10 | | }
| |_^
|
= note: #[warn(clippy::needless_lifetimes)] on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
However, I don't think I can use &'_:
error[E0106]: missing lifetime specifier
--> src/lib.rs:1:67
|
1 | pub fn sounder(div: u32, msg: &'_ str) -> impl Fn(u32) -> Option<&'_ str>
| ^^ help: consider giving it an explicit bounded or 'static lifetime: `'static`
|
= help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments
And I certainly can't just elide them:
error[E0106]: missing lifetime specifier
--> src/lib.rs:1:63
|
1 | pub fn sounder(div: u32, msg: &str) -> impl Fn(u32) -> Option<&str>
| ^ help: consider giving it an explicit bounded or 'static lifetime: `&'static`
|
= help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments
Is this a false positive? Using clippy 0.0.212 (e3cb40e 2019-06-25).
The text was updated successfully, but these errors were encountered:
I was doing some fizz buzz, and I had this code
Clippy is telling me that
However, I don't think I can use
&'_
:And I certainly can't just elide them:
Is this a false positive? Using
clippy 0.0.212 (e3cb40e 2019-06-25)
.The text was updated successfully, but these errors were encountered: