Given the following code:
pub fn strip_lf(s: &str) -> &str {
s.strip_suffix(b'\n').unwrap_or(s)
}
The current output is:
error[E0277]: expected a `FnMut<(char,)>` closure, found `u8`
--> src/lib.rs:2:20
|
2 | s.strip_suffix(b'\n').unwrap_or(s)
| ^^^^^ expected an `FnMut<(char,)>` closure, found `u8`
|
= help: the trait `FnMut<(char,)>` is not implemented for `u8`
= note: required because of the requirements on the impl of `Pattern<'_>` for `u8`
Pattern<'a> has implementations for:
char
&str
&String
&[char]
&&str
F where F: FnMut(char) -> bool
While it is true that u8 doesn't match any of the non-generic impls, and that it doesn't have an impl for FnMut<(char,)> -> bool, it's sad that the error message doesn't mention that those other possibilities exist.
(Also, the error message doesn't mention the closure return type)
Given the following code:
The current output is:
Pattern<'a>has implementations for:char&str&String&[char]&&strFwhereF: FnMut(char) -> boolWhile it is true that u8 doesn't match any of the non-generic impls, and that it doesn't have an impl for
FnMut<(char,)> -> bool, it's sad that the error message doesn't mention that those other possibilities exist.(Also, the error message doesn't mention the closure return type)