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

Commit

Permalink
Merge pull request #106 from p4l1ly/binary_int
Browse files Browse the repository at this point in the history
support binary format of integers, e.g. 0b0101
  • Loading branch information
dtolnay committed Sep 25, 2018
2 parents f14852b + 63eabe4 commit fedac77
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/de.rs
Expand Up @@ -542,6 +542,14 @@ where
return visitor.visit_i64(n);
}
}
if v.starts_with("0b") {
if let Ok(n) = u64::from_str_radix(&v[2..], 2) {
return visitor.visit_u64(n);
}
if let Ok(n) = i64::from_str_radix(&v[2..], 2) {
return visitor.visit_i64(n);
}
}
if v.starts_with('+') {
if let Ok(n) = v.parse() {
return visitor.visit_u64(n);
Expand Down

0 comments on commit fedac77

Please sign in to comment.