mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-22 06:48:00 +00:00
Resolve manual_let_else clippy lints
error: this could be rewritten as `let...else`
--> test_suite/tests/test_annotations.rs:1247:5
|
1247 | / let f1 = match pieces.next() {
1248 | | Some(x) => x,
1249 | | None => return Err(de::Error::invalid_length(0, &"2")),
1250 | | };
| |______^ help: consider writing: `let Some(x) = pieces.next() else { return Err(de::Error::invalid_length(0, &"2")) };`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else
= note: `-D clippy::manual-let-else` implied by `-D clippy::pedantic`
error: this could be rewritten as `let...else`
--> test_suite/tests/test_annotations.rs:1251:5
|
1251 | / let f2 = match pieces.next() {
1252 | | Some(x) => x,
1253 | | None => return Err(de::Error::invalid_length(1, &"2")),
1254 | | };
| |______^ help: consider writing: `let Some(x) = pieces.next() else { return Err(de::Error::invalid_length(1, &"2")) };`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else
error: this could be rewritten as `let...else`
--> test_suite/tests/test_annotations.rs:1255:5
|
1255 | / let f2 = match f2.parse() {
1256 | | Ok(n) => n,
1257 | | Err(_) => {
1258 | | return Err(de::Error::invalid_value(
... |
1262 | | }
1263 | | };
| |______^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else
help: consider writing
|
1255 ~ let Ok(n) = f2.parse() else {
1256 + return Err(de::Error::invalid_value(
1257 + Unexpected::Str(f2),
1258 + &"an 8-bit signed integer",
1259 + ));
1260 + };
|
This commit is contained in:
@@ -1244,22 +1244,17 @@ where
|
||||
{
|
||||
let s = String::deserialize(deserializer)?;
|
||||
let mut pieces = s.split(';');
|
||||
let f1 = match pieces.next() {
|
||||
Some(x) => x,
|
||||
None => return Err(de::Error::invalid_length(0, &"2")),
|
||||
let Some(f1) = pieces.next() else {
|
||||
return Err(de::Error::invalid_length(0, &"2"));
|
||||
};
|
||||
let f2 = match pieces.next() {
|
||||
Some(x) => x,
|
||||
None => return Err(de::Error::invalid_length(1, &"2")),
|
||||
let Some(f2) = pieces.next() else {
|
||||
return Err(de::Error::invalid_length(1, &"2"));
|
||||
};
|
||||
let f2 = match f2.parse() {
|
||||
Ok(n) => n,
|
||||
Err(_) => {
|
||||
return Err(de::Error::invalid_value(
|
||||
Unexpected::Str(f2),
|
||||
&"an 8-bit signed integer",
|
||||
));
|
||||
}
|
||||
let Ok(f2) = f2.parse() else {
|
||||
return Err(de::Error::invalid_value(
|
||||
Unexpected::Str(f2),
|
||||
&"an 8-bit signed integer",
|
||||
));
|
||||
};
|
||||
Ok((f1.into(), f2))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user