|
1 | 1 | //! Shared primitive types for use in SVD objects.
|
| 2 | +#![allow(clippy::manual_strip)] |
2 | 3 |
|
3 | 4 | use xmltree::Element;
|
4 | 5 |
|
@@ -34,11 +35,11 @@ impl Parse for u32 {
|
34 | 35 | 2,
|
35 | 36 | )
|
36 | 37 | .with_context(|| format!("{} invalid", text))
|
37 |
| - } else if let Some(digits) = text.strip_prefix("0b") { |
| 38 | + } else if text.starts_with("0b") { |
38 | 39 | // Handle strings in the binary form of:
|
39 | 40 | // 0b01101x1
|
40 | 41 | // along with don't care character x (replaced with 0)
|
41 |
| - u32::from_str_radix(&str::replace(digits, "x", "0"), 2) |
| 42 | + u32::from_str_radix(&str::replace(&text["0b".len()..], "x", "0"), 2) |
42 | 43 | .with_context(|| format!("{} invalid", text))
|
43 | 44 | } else {
|
44 | 45 | text.parse::<u32>()
|
@@ -66,11 +67,11 @@ impl Parse for u64 {
|
66 | 67 | 2,
|
67 | 68 | )
|
68 | 69 | .with_context(|| format!("{} invalid", text))
|
69 |
| - } else if let Some(digits) = text.strip_prefix("0b") { |
| 70 | + } else if text.starts_with("0b") { |
70 | 71 | // Handle strings in the binary form of:
|
71 | 72 | // 0b01101x1
|
72 | 73 | // along with don't care character x (replaced with 0)
|
73 |
| - u64::from_str_radix(&str::replace(digits, "x", "0"), 2) |
| 74 | + u64::from_str_radix(&str::replace(&text["0b".len()..], "x", "0"), 2) |
74 | 75 | .with_context(|| format!("{} invalid", text))
|
75 | 76 | } else {
|
76 | 77 | text.parse::<u64>()
|
|
0 commit comments