Skip to content

Commit 9a57c97

Browse files
authored
Enable edition 2018 (#57)
* Update MSRV in CI and Readme from 1.29 to 1.41.1 It seems we have consensus within the rust-bitcoin github organisation on bumping the MSRV to 1.41.1, update CI job and the README to reflect this. * Update to use edition 2018 Add `edition = 2018` to the manifest file. No further changes were necessary. * Remove unneeded reference Clippy emits: error: this expression borrows a reference (`&str`) that is immediately dereferenced by the compiler As suggested, remove the unneeded reference. * Use long literal separators Clippy emits: warning: long literal lacking separators As suggested, use separators. * Use contains combinator instead of manual impl Clippy emits: warning: manual `!RangeInclusive::contains` implementation Use the code snippets suggested by clippy. * Allow type_complexity Clippy emits: warning: very complex type used. Consider factoring parts into `type` definitions This code is in a unit test, its clear enough for the purpose. Configure clippy to allow type_complexity * Bump version 0.8.1 -> 0.9.0 We just bumped the MSRV, this is a major change but since we are pre 1.0 we just have to bump the minor version number. Bump version from current `0.8.1` to `0.9.0`.
1 parent e063fe7 commit 9a57c97

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
matrix:
1111
rust:
12-
- 1.29.0
12+
- 1.41.1
1313
- stable
1414
- nightly
1515
steps:

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
[package]
22
name = "bech32"
3-
version = "0.8.1"
3+
version = "0.9.0"
44
authors = ["Clark Moody"]
55
repository = "https://github.com/rust-bitcoin/rust-bech32"
66
description = "Encodes and decodes the Bech32 format"
77
readme = "README.md"
88
keywords = ["base32", "encoding", "bech32"]
99
categories = ["encoding"]
1010
license = "MIT"
11+
edition = "2018"
1112

1213
[features]
1314
default = ["std"]

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,5 @@ You can find some usage examples in the [documentation](https://docs.rs/bech32/)
1010
Bitcoin-specific address encoding is handled by the `bitcoin-bech32` crate.
1111

1212
# MSRV
13-
The minimum supported Rust version with the standard library is **1.29**.
14-
15-
With nostd, we use the `alloc` dependency, so the MSRV is instead **1.36**.
13+
The minimum supported Rust version with the standard library is **1.41.1**.
1614

clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
msrv = "1.29.0"
1+
msrv = "1.41.1"

src/lib.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -370,13 +370,13 @@ fn check_hrp(hrp: &str) -> Result<Case, Error> {
370370
let mut has_upper: bool = false;
371371
for b in hrp.bytes() {
372372
// Valid subset of ASCII
373-
if b < 33 || b > 126 {
373+
if !(33..=126).contains(&b) {
374374
return Err(Error::InvalidChar(b as char));
375375
}
376376

377-
if b >= b'a' && b <= b'z' {
377+
if (b'a'..=b'z').contains(&b) {
378378
has_lower = true;
379-
} else if b >= b'A' && b <= b'Z' {
379+
} else if (b'A'..=b'Z').contains(&b) {
380380
has_upper = true;
381381
};
382382

@@ -406,7 +406,7 @@ pub fn encode_to_fmt<T: AsRef<[u5]>>(
406406
data: T,
407407
variant: Variant,
408408
) -> Result<fmt::Result, Error> {
409-
let hrp_lower = match check_hrp(&hrp)? {
409+
let hrp_lower = match check_hrp(hrp)? {
410410
Case::Upper => Cow::Owned(hrp.to_lowercase()),
411411
Case::Lower | Case::None => Cow::Borrowed(hrp),
412412
};
@@ -432,7 +432,7 @@ pub enum Variant {
432432
}
433433

434434
const BECH32_CONST: u32 = 1;
435-
const BECH32M_CONST: u32 = 0x2bc830a3;
435+
const BECH32M_CONST: u32 = 0x2bc8_30a3;
436436

437437
impl Variant {
438438
// Produce the variant based on the remainder of the polymod operation
@@ -485,7 +485,7 @@ pub fn decode(s: &str) -> Result<(String, Vec<u5>, Variant), Error> {
485485
return Err(Error::InvalidLength);
486486
}
487487

488-
let mut case = check_hrp(&raw_hrp)?;
488+
let mut case = check_hrp(raw_hrp)?;
489489
let hrp_lower = match case {
490490
Case::Upper => raw_hrp.to_lowercase(),
491491
// already lowercase
@@ -520,7 +520,7 @@ pub fn decode(s: &str) -> Result<(String, Vec<u5>, Variant), Error> {
520520
// c should be <128 since it is in the ASCII range, CHARSET_REV.len() == 128
521521
let num_value = CHARSET_REV[c as usize];
522522

523-
if num_value > 31 || num_value < 0 {
523+
if !(0..=31).contains(&num_value) {
524524
return Err(Error::InvalidChar(c));
525525
}
526526

@@ -529,7 +529,7 @@ pub fn decode(s: &str) -> Result<(String, Vec<u5>, Variant), Error> {
529529
.collect::<Result<Vec<u5>, Error>>()?;
530530

531531
// Ensure checksum
532-
match verify_checksum(&hrp_lower.as_bytes(), &data) {
532+
match verify_checksum(hrp_lower.as_bytes(), &data) {
533533
Some(variant) => {
534534
// Remove checksum from data payload
535535
let dbl: usize = data.len();
@@ -803,6 +803,7 @@ mod tests {
803803
}
804804

805805
#[test]
806+
#[allow(clippy::type_complexity)]
806807
fn valid_conversion() {
807808
// Set of [data, from_bits, to_bits, pad, result]
808809
let tests: Vec<(Vec<u8>, u32, u32, bool, Vec<u8>)> = vec![

0 commit comments

Comments
 (0)