Skip to content

Commit 8d242de

Browse files
committed
revert strip_prefix
1 parent 91f7976 commit 8d242de

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/error.rs

+1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ pub(crate) fn check_reset_value(
158158
Ok(())
159159
}
160160

161+
#[cfg(feature = "strict")]
161162
#[cfg(test)]
162163
mod tests {
163164
use crate::error::check_reset_value;

src/types.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Shared primitive types for use in SVD objects.
2+
#![allow(clippy::manual_strip)]
23

34
use xmltree::Element;
45

@@ -34,11 +35,11 @@ impl Parse for u32 {
3435
2,
3536
)
3637
.with_context(|| format!("{} invalid", text))
37-
} else if let Some(digits) = text.strip_prefix("0b") {
38+
} else if text.starts_with("0b") {
3839
// Handle strings in the binary form of:
3940
// 0b01101x1
4041
// 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)
4243
.with_context(|| format!("{} invalid", text))
4344
} else {
4445
text.parse::<u32>()
@@ -66,11 +67,11 @@ impl Parse for u64 {
6667
2,
6768
)
6869
.with_context(|| format!("{} invalid", text))
69-
} else if let Some(digits) = text.strip_prefix("0b") {
70+
} else if text.starts_with("0b") {
7071
// Handle strings in the binary form of:
7172
// 0b01101x1
7273
// 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)
7475
.with_context(|| format!("{} invalid", text))
7576
} else {
7677
text.parse::<u64>()

0 commit comments

Comments
 (0)