diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ede8ae22..9f9af140 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -57,26 +57,21 @@ jobs: - name: Install Rust toolchain uses: artichoke/setup-rust/build-and-test@v2.0.0 with: - toolchain: "1.42.0" + toolchain: "1.83.0" - name: Compile run: cargo build --verbose - # skip tests because dev dependencies have a higher MSRV than boba does. - name: Compile tests - if: false run: cargo test --no-run - name: Test - if: false run: cargo test - name: Test with all features - if: false run: cargo test --all-features - name: Test with no default features - if: false run: cargo test --no-default-features rust-minimal-versions: diff --git a/Cargo.toml b/Cargo.toml index e4f836ef..764a7348 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,8 +3,8 @@ name = "boba" version = "5.0.0" # remember to set `html_root_url` in `src/lib.rs`. authors = ["Ryan Lopopolo "] license = "MIT" -edition = "2018" -rust-version = "1.42.0" +edition = "2021" +rust-version = "1.83.0" readme = "README.md" repository = "https://github.com/artichoke/boba" documentation = "https://docs.rs/boba" @@ -15,10 +15,6 @@ categories = ["encoding", "no-std"] include = ["src/**/*", "tests/**/*", "LICENSE", "README.md"] [features] -default = ["std"] -# Enable dependency on `std`, the Rust standard library. This feature enables -# `std::error::Error` implementations on the error types in `boba`. -std = [] [dependencies] diff --git a/README.md b/README.md index efd1d294..213ff852 100644 --- a/README.md +++ b/README.md @@ -37,17 +37,11 @@ assert_eq!(boba::decode(b"xexax"), Ok(vec![])); Boba is `no_std` compatible with a required dependency on the [`alloc`] crate. -Boba has several Cargo features, all of which are enabled by default: - -- **std** - Adds a dependency on [`std`], the Rust Standard Library. This - feature enables [`std::error::Error`] implementations on error types in this - crate. Enabling the **std** feature also enables the **alloc** feature. - `boba` is [fuzzed](fuzz/fuzz_targets) with [cargo-fuzz]. ## Minimum Rust Version Policy -This crate's minimum supported `rustc` version (MSRV) is `1.42.0`. +This crate's minimum supported `rustc` version (MSRV) is `1.83.0`. MSRV may be bumped in minor version releases. diff --git a/src/decode.rs b/src/decode.rs index 465505d3..d399afa5 100644 --- a/src/decode.rs +++ b/src/decode.rs @@ -52,7 +52,7 @@ pub fn inner(encoded: &[u8]) -> Result, DecodeError> { if let Some((_, pos)) = enc .iter() .zip(1_usize..) // start `pos` at 1 because we stripped off a leading 'x' - .find(|(&byte, _)| ALPHABET_TABLE[usize::from(byte)] == 0) + .find(|&(&byte, _)| ALPHABET_TABLE[usize::from(byte)] == 0) { return Err(DecodeError::InvalidByte(pos)); } diff --git a/src/lib.rs b/src/lib.rs index 36959925..bb001ca2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,6 +7,8 @@ #![warn(missing_docs)] #![warn(missing_debug_implementations)] #![warn(rust_2018_idioms)] +#![warn(rust_2021_compatibility)] +#![warn(rust_2024_compatibility)] #![warn(trivial_casts, trivial_numeric_casts)] #![warn(unused_qualifications)] #![warn(variant_size_differences)] @@ -28,6 +30,9 @@ //! Bubble Babble is part of the Digest libraries in [Perl][perl-bubblebabble] //! and [Ruby][ruby-bubblebabble]. //! +//! [perl-bubblebabble]: https://metacpan.org/pod/Digest::BubbleBabble +//! [ruby-bubblebabble]: https://ruby-doc.org/stdlib-3.1.1/libdoc/digest/rdoc/Digest.html#method-c-bubblebabble +//! //! # Usage //! //! You can encode binary data by calling [`encode`](encode()): @@ -64,31 +69,11 @@ //! //! Boba is `no_std` compatible with a required dependency on the [`alloc`] //! crate. -//! -//! Boba has several Cargo features, all of which are enabled by default: -//! -//! - **std** - Adds a dependency on [`std`], the Rust Standard Library. This -//! feature enables [`std::error::Error`] implementations on error types in -//! this crate. Enabling the **std** feature also enables the **alloc** -//! feature. -//! -#![cfg_attr( - not(feature = "std"), - doc = "[`std`]: https://doc.rust-lang.org/stable/std/index.html" -)] -#![cfg_attr( - not(feature = "std"), - doc = "[`std::error::Error`]: https://doc.rust-lang.org/stable/std/error/trait.Error.html" -)] -//! [perl-bubblebabble]: https://metacpan.org/pod/Digest::BubbleBabble -//! [ruby-bubblebabble]: https://ruby-doc.org/stdlib-3.1.1/libdoc/digest/rdoc/Digest.html#method-c-bubblebabble #![no_std] #![doc(html_root_url = "https://docs.rs/boba/5.0.0")] extern crate alloc; -#[cfg(feature = "std")] -extern crate std; use alloc::string::String; use alloc::vec::Vec; @@ -140,8 +125,7 @@ pub enum DecodeError { MalformedTrailer, } -#[cfg(feature = "std")] -impl std::error::Error for DecodeError {} +impl core::error::Error for DecodeError {} impl fmt::Display for DecodeError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -152,8 +136,7 @@ impl fmt::Display for DecodeError { Self::ExpectedVowel => f.write_str("Expected vowel, got something else"), Self::InvalidByte(pos) => write!( f, - "Encountered byte outside of encoding alphabet at position {}", - pos + "Encountered byte outside of encoding alphabet at position {pos}" ), Self::MalformedHeader => f.write_str("Missing required 'x' header"), Self::MalformedTrailer => f.write_str("Missing required 'x' trailer"), @@ -332,7 +315,7 @@ mod tests { ]; for tc in test_cases { let mut buf = String::new(); - write!(&mut buf, "{}", tc).unwrap(); + write!(&mut buf, "{tc}").unwrap(); assert!(!buf.is_empty()); } } @@ -355,14 +338,5 @@ mod tests { // This module and macro declaration should be kept at the end of the file, in // order to not interfere with code coverage. #[cfg(doctest)] -macro_rules! readme { - ($x:expr) => { - #[doc = $x] - mod readme {} - }; - () => { - readme!(include_str!("../README.md")); - }; -} -#[cfg(doctest)] -readme!(); +#[doc = include_str!("../README.md")] +mod readme {}