diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml index 333e134..cea3e1d 100644 --- a/.github/workflows/pre-commit.yaml +++ b/.github/workflows/pre-commit.yaml @@ -30,6 +30,8 @@ jobs: - name: Check out repository uses: actions/checkout@v4 + with: + persist-credentials: false - name: Generate Cargo.lock run: cargo generate-lockfile @@ -41,11 +43,11 @@ jobs: shared-key: ${{ github.workflow }}-${{ github.job }} - name: Detect code style issues (push) - uses: pre-commit/action@v3.0.0 + uses: pre-commit/action@v3.0.1 if: github.event_name == 'push' - name: Detect code style issues (pull_request) - uses: pre-commit/action@v3.0.0 + uses: pre-commit/action@v3.0.1 if: github.event_name == 'pull_request' env: SKIP: no-commit-to-branch diff --git a/.github/workflows/security-audit.yaml b/.github/workflows/security-audit.yaml index 369a734..565870a 100644 --- a/.github/workflows/security-audit.yaml +++ b/.github/workflows/security-audit.yaml @@ -26,10 +26,15 @@ jobs: # has been resolved. - uses: dtolnay/rust-toolchain@stable + - name: Install cargo-binstall + uses: cargo-bins/cargo-binstall@main + - name: Install cargo-audit - run: cargo install cargo-audit + run: cargo binstall cargo-audit - uses: actions/checkout@v4 + with: + persist-credentials: false - name: Cache Rust toolchain and build artifacts uses: Swatinem/rust-cache@v2 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b1a9146..84fb89d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,11 +4,11 @@ default_stages: # Prevent that hooks run twice, triggered by both # the Git commit-msg and the pre-commit hook. - - commit + - pre-commit repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-case-conflict - id: check-json @@ -25,17 +25,17 @@ repos: - id: mixed-line-ending - id: trailing-whitespace - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook - rev: v9.16.0 + rev: v9.22.0 hooks: - id: commitlint stages: - commit-msg - repo: https://github.com/DavidAnson/markdownlint-cli2 - rev: v0.13.0 + rev: v0.17.2 hooks: - id: markdownlint-cli2 - repo: https://github.com/codespell-project/codespell - rev: v2.3.0 + rev: v2.4.1 hooks: - id: codespell args: [--ignore-words=.codespellignore] @@ -48,7 +48,7 @@ repos: - yaml # https://reuse.software - repo: https://github.com/fsfe/reuse-tool - rev: v4.0.3 + rev: v5.0.2 hooks: - id: reuse - repo: https://github.com/doublify/pre-commit-rust diff --git a/Cargo.toml b/Cargo.toml index 044ac1b..a6fb480 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,11 +11,11 @@ readme = "README.md" authors = ["slowtec GmbH ", "Uwe Klotz "] repository = "https://github.com/slowtec/semval" categories = ["no-std", "rust-patterns"] -edition = "2021" +edition = "2024" include = ["CHANGELOG.md", "README.md", "LICENSES/", "src/"] [dependencies] -smallvec = { version = "1.13.1", features = ["union"] } +smallvec = { version = "1.14.0", features = ["union"] } [features] default = ["std"] @@ -27,6 +27,7 @@ let_underscore = "warn" missing_debug_implementations = "warn" rust_2018_idioms = "warn" rust_2021_compatibility = "warn" +rust_2024_compatibility = "warn" unreachable_pub = "warn" unsafe_code = "warn" unused = "warn" diff --git a/src/context.rs b/src/context.rs index 0c2381b..c841c46 100644 --- a/src/context.rs +++ b/src/context.rs @@ -4,9 +4,9 @@ use core::iter::once; use crate::{ + Invalidity, Validate, ValidationResult, smallvec::SmallVec, util::{IsEmpty, Mergeable, MergeableSized}, - Invalidity, Validate, ValidationResult, }; const SMALLVEC_ARRAY_LEN: usize = 8; @@ -162,11 +162,7 @@ where /// validations failed. #[inline] pub fn into_result(self) -> ValidationResult { - if self.is_valid() { - Ok(()) - } else { - Err(self) - } + if self.is_valid() { Ok(()) } else { Err(self) } } } diff --git a/src/lib.rs b/src/lib.rs index c97c371..2fb9436 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,8 +27,8 @@ use self::util::UnitResult; /// A proposed set of imports to ease usage of this crate. pub mod prelude { pub use super::{ - context::Context as ValidationContext, IntoValidated, Invalidity, IsValid, Validate, - Validated, ValidatedFrom, ValidatedResult, ValidationResult, + IntoValidated, Invalidity, IsValid, Validate, Validated, ValidatedFrom, ValidatedResult, + ValidationResult, context::Context as ValidationContext, }; } @@ -96,7 +96,7 @@ where /// `Validate` is implemented for any reference of a type /// that implements `Validate`. -impl<'a, V> Validate for &'a V +impl Validate for &V where V: Validate + ?Sized, { @@ -119,7 +119,7 @@ where type Invalidity = V::Invalidity; fn validate(&self) -> ValidationResult { - if let Some(ref some) = self { + if let Some(some) = self { some.validate() } else { Ok(()) diff --git a/src/util.rs b/src/util.rs index a294cb9..975a636 100644 --- a/src/util.rs +++ b/src/util.rs @@ -27,7 +27,7 @@ impl IsEmpty for usize { } /////////////////////////////////////////////////////////////////////////////// -/// Mergeable +// Mergeable /////////////////////////////////////////////////////////////////////////////// /// A monoid for collecting or accumulating items