From e191f4ea725bf3cadd7def3a643d17a103b9aefa Mon Sep 17 00:00:00 2001 From: jan-kubica Date: Thu, 19 Nov 2026 09:55:26 +0100 Subject: [PATCH] chore(rust): adopt Rust 1.100 trim helpers and the unused-dependency lint Replace strip_prefix/strip_suffix followed by unwrap_or(self) with the standard trim_prefix/trim_suffix, raise rust-version to 1.100, and deny cargo::unused_dependencies across the workspace. --- .changeset/rust-1-100-std-apis.md | 5 +++++ CONTRIBUTING.md | 2 +- Cargo.toml | 5 ++++- crates/stdnum-core/src/validators/additional_a_m.rs | 2 +- crates/stdnum-core/src/validators/legacy_specs.rs | 2 +- crates/stdnum-wasm-size-fixture/Cargo.toml | 2 +- 6 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 .changeset/rust-1-100-std-apis.md diff --git a/.changeset/rust-1-100-std-apis.md b/.changeset/rust-1-100-std-apis.md new file mode 100644 index 00000000..d1f9d267 --- /dev/null +++ b/.changeset/rust-1-100-std-apis.md @@ -0,0 +1,5 @@ +--- +"@stll/stdnum": patch +--- + +Raise the Rust crates' minimum supported Rust version to 1.100, use the standard `trim_prefix` and `trim_suffix` string helpers, and reject unused Cargo dependencies at build time. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6ce1ab91..0b7086b4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,7 +13,7 @@ a pull request. ## Development setup ```bash -# Prerequisites: Bun and Rust 1.96 +# Prerequisites: Bun and Rust 1.100 bun install bun run rust:check # lint and test the Rust implementation bun run codegen:check # verify generated bindings, types, and README diff --git a/Cargo.toml b/Cargo.toml index 3e883f08..5ecbaf0f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ version = "2.3.2" edition = "2024" # Minimum supported Rust version; CI uses the shared stable toolchain. # Resolver "3" keeps dependency resolution MSRV-aware. -rust-version = "1.96" +rust-version = "1.100" license = "Apache-2.0" publish = false repository = "https://github.com/stella/stdnum" @@ -33,6 +33,9 @@ unused_macros = "deny" unused_mut = "deny" unused_variables = "deny" +[workspace.lints.cargo] +unused_dependencies = "deny" + [workspace.lints.rustdoc] broken_intra_doc_links = "deny" bare_urls = "deny" diff --git a/crates/stdnum-core/src/validators/additional_a_m.rs b/crates/stdnum-core/src/validators/additional_a_m.rs index b3240384..ec71bb41 100644 --- a/crates/stdnum-core/src/validators/additional_a_m.rs +++ b/crates/stdnum-core/src/validators/additional_a_m.rs @@ -347,7 +347,7 @@ fn compact_for(id: &str, value: &str) -> String { } compact } - "cl.rut" => upper.strip_prefix("CL").unwrap_or(&upper).to_owned(), + "cl.rut" => upper.trim_prefix("CL").to_owned(), "gt.nit" => upper.trim_start_matches('0').to_owned(), "il.idnr" => format!("{compact:0>9}"), "eg.tn" | "iq.nid" | "ir.nid" => compact diff --git a/crates/stdnum-core/src/validators/legacy_specs.rs b/crates/stdnum-core/src/validators/legacy_specs.rs index 6e177f70..7df26c1a 100644 --- a/crates/stdnum-core/src/validators/legacy_specs.rs +++ b/crates/stdnum-core/src/validators/legacy_specs.rs @@ -1340,7 +1340,7 @@ fn format_for(id: &str, value: &str) -> String { span(&v, 7, v.len()) ), "no.mva" => { - let d = v.strip_suffix("MVA").unwrap_or(&v); + let d = v.trim_suffix("MVA"); format!( "NO {} {} {} MVA", span(d, 0, 3), diff --git a/crates/stdnum-wasm-size-fixture/Cargo.toml b/crates/stdnum-wasm-size-fixture/Cargo.toml index a16cbd4f..00d9843c 100644 --- a/crates/stdnum-wasm-size-fixture/Cargo.toml +++ b/crates/stdnum-wasm-size-fixture/Cargo.toml @@ -2,7 +2,7 @@ name = "stella-stdnum-wasm-size-fixture" version = "0.0.0" edition = "2024" -rust-version = "1.96" +rust-version = "1.100" license = "Apache-2.0" publish = false