Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
Resolve manual_strip clippy lint
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jul 9, 2022
1 parent cc65145 commit a7fbcc8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
27 changes: 12 additions & 15 deletions src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -951,38 +951,35 @@ where
if v == "false" {
return visitor.visit_bool(false);
}
if v.starts_with("0x") || v.starts_with("+0x") {
let start = 2 + v.starts_with('+') as usize;
if let Ok(n) = u64::from_str_radix(&v[start..], 16) {
if let Some(rest) = Option::or(v.strip_prefix("0x"), v.strip_prefix("+0x")) {
if let Ok(n) = u64::from_str_radix(rest, 16) {
return visitor.visit_u64(n);
}
}
if v.starts_with("-0x") {
let negative = format!("-{}", &v[3..]);
if let Some(rest) = v.strip_prefix("-0x") {
let negative = format!("-{}", rest);
if let Ok(n) = i64::from_str_radix(&negative, 16) {
return visitor.visit_i64(n);
}
}
if v.starts_with("0o") || v.starts_with("+0o") {
let start = 2 + v.starts_with('+') as usize;
if let Ok(n) = u64::from_str_radix(&v[start..], 8) {
if let Some(rest) = Option::or(v.strip_prefix("0o"), v.strip_prefix("+0o")) {
if let Ok(n) = u64::from_str_radix(rest, 8) {
return visitor.visit_u64(n);
}
}
if v.starts_with("-0o") {
let negative = format!("-{}", &v[3..]);
if let Some(rest) = v.strip_prefix("-0o") {
let negative = format!("-{}", rest);
if let Ok(n) = i64::from_str_radix(&negative, 8) {
return visitor.visit_i64(n);
}
}
if v.starts_with("0b") || v.starts_with("+0b") {
let start = 2 + v.starts_with('+') as usize;
if let Ok(n) = u64::from_str_radix(&v[start..], 2) {
if let Some(rest) = Option::or(v.strip_prefix("0b"), v.strip_prefix("+0b")) {
if let Ok(n) = u64::from_str_radix(rest, 2) {
return visitor.visit_u64(n);
}
}
if v.starts_with("-0b") {
let negative = format!("-{}", &v[3..]);
if let Some(rest) = v.strip_prefix("-0b") {
let negative = format!("-{}", rest);
if let Ok(n) = i64::from_str_radix(&negative, 2) {
return visitor.visit_i64(n);
}
Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@
// noisy
clippy::missing_errors_doc,
clippy::must_use_candidate,
// todo
clippy::manual_strip,
)]

pub use crate::de::{from_reader, from_slice, from_str, Deserializer};
Expand Down

0 comments on commit a7fbcc8

Please sign in to comment.