Skip to content

Commit efdc72f

Browse files
committed
fix build on 1.48.0
1 parent e0b8c82 commit efdc72f

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

contrib/test.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ if [ "${DO_FEATURE_MATRIX-false}" = true ]; then
4949
build_and_test "alloc"
5050
build_and_test "std alloc"
5151
# arrayvec breaks the MSRV
52-
if [ $MSRV = false
53-
]; then
52+
if [ $MSRV = false ]; then
5453
build_and_test "arrayvec"
5554
build_and_test "std arrayvec"
5655
build_and_test "alloc arrayvec"

src/primitives/gf32.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,8 @@ mod tests {
411411

412412
#[test]
413413
fn from_char() {
414-
for c in CHARS_LOWER {
415-
assert!(Fe32::from_char(c).is_ok())
414+
for c in &CHARS_LOWER[..] {
415+
assert!(Fe32::from_char(*c).is_ok())
416416
}
417417
}
418418

@@ -426,8 +426,8 @@ mod tests {
426426

427427
#[test]
428428
fn mul_zero() {
429-
for c in CHARS_LOWER {
430-
let fe = Fe32::from_char(c).unwrap();
429+
for c in &CHARS_LOWER[..] {
430+
let fe = Fe32::from_char(*c).unwrap();
431431
assert_eq!(fe._mul(Fe32::Q), Fe32::Q) // Fe32::Q == Fe32(0)
432432
}
433433
}
@@ -446,8 +446,8 @@ mod tests {
446446

447447
#[test]
448448
fn mul_one() {
449-
for c in CHARS_LOWER {
450-
let fe = Fe32::from_char(c).unwrap();
449+
for c in &CHARS_LOWER[..] {
450+
let fe = Fe32::from_char(*c).unwrap();
451451
assert_eq!(fe * Fe32::P, fe) // Fe32::P == Fe32(1)
452452
}
453453
}

src/primitives/hrp.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,22 @@ impl Hrp {
4646

4747
/// Parses the human-readable part (see [`Hrp::parse`] for full docs).
4848
///
49-
/// # Panics
50-
///
51-
/// If the string is invalid as defined by BIP-173.
49+
/// Does not check that `hrp` is valid according to BIP-173 but does check for valid ASCII
50+
/// values, replacing any invalid characters with `X`.
5251
pub const fn parse_unchecked(hrp: &str) -> Self {
5352
let mut new = Hrp { buf: [0_u8; MAX_HRP_LEN], size: 0 };
5453
let hrp_bytes = hrp.as_bytes();
5554

5655
let mut i = 0;
5756
// Funky code so we can be const.
5857
while i < hrp.len() {
59-
let b = hrp_bytes[i];
58+
let mut b = hrp_bytes[i];
6059
// Valid subset of ASCII
6160
if b < 33 || b > 126 {
62-
panic!("invalid hrp");
61+
b = b'X';
6362
}
6463

65-
new.buf[i] = hrp_bytes[i];
64+
new.buf[i] = b;
6665
new.size += 1;
6766
i += 1;
6867
}

0 commit comments

Comments
 (0)