Skip to content

Commit cfe867a

Browse files
committed
revert strip_prefix
1 parent 91f7976 commit cfe867a

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

.github/workflows/clippy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- uses: actions-rs/toolchain@v1
1313
with:
1414
profile: minimal
15-
toolchain: stable
15+
toolchain: 1.40.0
1616
override: true
1717
components: clippy
1818
- uses: actions-rs/clippy-check@v1

src/error.rs

Lines changed: 1 addition & 0 deletions
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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ impl Parse for u32 {
3434
2,
3535
)
3636
.with_context(|| format!("{} invalid", text))
37-
} else if let Some(digits) = text.strip_prefix("0b") {
37+
} else if text.starts_with("0b") {
3838
// Handle strings in the binary form of:
3939
// 0b01101x1
4040
// along with don't care character x (replaced with 0)
41-
u32::from_str_radix(&str::replace(digits, "x", "0"), 2)
41+
u32::from_str_radix(&str::replace(&text["0b".len()..], "x", "0"), 2)
4242
.with_context(|| format!("{} invalid", text))
4343
} else {
4444
text.parse::<u32>()
@@ -66,11 +66,11 @@ impl Parse for u64 {
6666
2,
6767
)
6868
.with_context(|| format!("{} invalid", text))
69-
} else if let Some(digits) = text.strip_prefix("0b") {
69+
} else if text.starts_with("0b") {
7070
// Handle strings in the binary form of:
7171
// 0b01101x1
7272
// along with don't care character x (replaced with 0)
73-
u64::from_str_radix(&str::replace(digits, "x", "0"), 2)
73+
u64::from_str_radix(&str::replace(&text["0b".len()..], "x", "0"), 2)
7474
.with_context(|| format!("{} invalid", text))
7575
} else {
7676
text.parse::<u64>()

0 commit comments

Comments
 (0)