Skip to content

Commit e811206

Browse files
committed
Upgrade to Rust 2024 edition
1 parent 92eeef9 commit e811206

File tree

20 files changed

+83
-99
lines changed

20 files changed

+83
-99
lines changed

.rustfmt.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
style_edition = "2021"
1+
style_edition = "2024"
22
unstable_features = true
33

44
blank_lines_lower_bound = 0

Cargo.toml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ license = "BSD-2-Clause"
1010
homepage = "https://kitoken.dev"
1111
repository = "https://github.com/Systemcluster/kitoken"
1212
readme = "README.md"
13-
edition = "2021"
13+
edition = "2024"
1414
resolver = "2"
15-
rust-version = "1.82.0"
15+
rust-version = "1.86.0"
1616
include = [
1717
"Cargo.toml",
1818
"src/**/*",
@@ -59,7 +59,7 @@ all = [
5959
]
6060

6161
# Enables standard library features
62-
std = ["dep:thiserror", "orx-priority-queue/std", "memchr/std", "multiversion?/std"]
62+
std = ["thiserror/std", "orx-priority-queue/std", "memchr/std", "multiversion?/std"]
6363

6464
# Enables serialization and deserialization
6565
serialization = ["dep:serde", "dep:postcard"]
@@ -105,9 +105,9 @@ unstable = []
105105

106106
[dependencies]
107107

108-
bstr = { version = "1.11", default-features = false, features = ["alloc"] }
108+
bstr = { version = "1.12", default-features = false, features = ["alloc"] }
109109
log = { version = "0.4" }
110-
fancy-regex = { version = "0.14", default-features = false }
110+
fancy-regex = { version = "0.16", default-features = false }
111111
regex-automata = { version = "0.4", default-features = false, features = [
112112
"alloc",
113113
"syntax",
@@ -124,21 +124,19 @@ regex-syntax = { version = "0.8", default-features = false, features = [
124124
"unicode-gencat",
125125
"unicode-case",
126126
] }
127-
hashbrown = { version = "0.15", default-features = false, features = ["default-hasher", "inline-more", "allocator-api2"] }
128-
once_cell = { version = "1.20", default-features = false, features = ["alloc", "race"] }
129-
orx-priority-queue = { version = "1.4", default-features = false }
127+
hashbrown = { version = "0.16", default-features = false, features = ["default-hasher", "inline-more", "allocator-api2"] }
128+
once_cell = { version = "1.21", default-features = false, features = ["alloc", "race"] }
129+
orx-priority-queue = { version = "1.7", default-features = false }
130130
memchr = { version = "2.7", default-features = false, features = ["alloc"] }
131131
derive_more = { version = "2.0", default-features = false, features = ["deref", "deref_mut", "as_ref", "index", "index_mut"] }
132-
133-
# optional dependencies for the std feature
134-
thiserror = { version = "1.0", optional = true }
132+
thiserror = { version = "2.0", default-features = false }
135133

136134
# optional dependencies for the serialization feature
137135
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"], optional = true }
138136
postcard = { version = "1.1", default-features = false, features = ["alloc"], optional = true }
139137

140138
# optional dependencies for the regex-onig feature
141-
onig = { version = "6.4", default-features = false, optional = true }
139+
onig = { version = "6.5", default-features = false, optional = true }
142140

143141
# optional dependencies for the normalization-unicode feature
144142
unicode-normalization = { version = "0.1", optional = true }
@@ -170,9 +168,9 @@ kitoken = { path = ".", default-features = false, features = [
170168
"multiversion",
171169
] }
172170

173-
console = { version = "0.15", features = ["windows-console-colors"] }
171+
console = { version = "0.16", features = ["windows-console-colors"] }
174172
simple_logger = { version = "5.0" }
175-
criterion = { version = "0.5", default-features = false, features = ["cargo_bench_support"] }
173+
criterion = { version = "0.7", default-features = false, features = ["cargo_bench_support"] }
176174

177175

178176
[package.metadata.docs.rs]

packages/javascript/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
name = "kitoken-javascript"
44
description = "JavaScript bindings for Kitoken"
55
version = "0.10.1"
6-
edition = "2021"
6+
edition = "2024"
77
resolver = "2"
88
publish = false
99
workspace = "../.."
@@ -24,7 +24,7 @@ default = [
2424
"normalization",
2525
]
2626

27-
std = ["kitoken/std", "wasm-bindgen/std"]
27+
std = ["kitoken/std", "wasm-bindgen/std", "rlsf/std"]
2828
serialization = ["kitoken/serialization"]
2929
normalization = ["kitoken/normalization"]
3030
regex-unicode = ["kitoken/regex-unicode"]
@@ -39,8 +39,8 @@ inspect = []
3939

4040
kitoken = { path = "../..", default-features = false, features = [] }
4141

42-
log = { version = "0.4.25" }
43-
rlsf = { version = "0.2.1", features = ["std"] }
42+
log = { version = "0.4.27" }
43+
rlsf = { version = "0.2.1" }
4444
wasm-bindgen = { version = "0.2.100", default-features = false, features = ["spans", "strict-macro"] }
4545
serde-wasm-bindgen = { version = "0.6.5" }
4646

packages/javascript/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@
5353
"./dist/*"
5454
],
5555
"scripts": {
56-
"build:node": "wasm-pack build --release --no-pack --target nodejs --out-dir dist --out-name node --features convert,split,regex-perf,inspect -Zbuild-std=panic_abort,core,alloc,std && move-file dist/node.js dist/node.cjs",
57-
"build:web": "wasm-pack build --release --no-pack --target web --out-dir dist --out-name web --features convert,inspect -Zbuild-std=panic_abort,core,alloc,std",
58-
"build:bundler": "wasm-pack build --release --no-pack --target bundler --out-dir dist --out-name index --features convert,inspect -Zbuild-std=panic_abort,core,alloc,std",
59-
"build:minimal": "wasm-pack build --release --no-pack --target bundler --out-dir dist --out-name minimal --features default -Zbuild-std=panic_abort,core,alloc,std",
60-
"build:full": "wasm-pack build --release --no-pack --target bundler --out-dir dist --out-name full --features convert,split,regex-perf,inspect -Zbuild-std=panic_abort,core,alloc,std",
61-
"build": "cross-env RUSTC_BOOTSTRAP=1 RUSTFLAGS=\"-Ctarget-feature=+crt-static,+sign-ext,+bulk-memory,+mutable-globals,+nontrapping-fptoint,+multivalue,+reference-types -Zwasm-c-abi=spec\" concurrently -m 1 'npm:build:node' 'npm:build:web' 'npm:build:bundler' 'npm:build:minimal' 'npm:build:full'",
62-
"prepare": "cross-env RUSTC_BOOTSTRAP=1 RUSTFLAGS=\"-Ctarget-feature=+crt-static,+sign-ext,+bulk-memory,+mutable-globals,+nontrapping-fptoint,+multivalue,+reference-types -Zwasm-c-abi=spec\" concurrently -m 1 'npm:build:node' 'npm:build:web' 'npm:build:bundler' 'npm:build:minimal' 'npm:build:full'"
56+
"build:node": "wasm-pack build --release --no-pack --target nodejs --out-dir dist --out-name node --features std,convert,split,regex-perf,inspect -Zbuild-std=panic_abort,core,alloc,std && move-file dist/node.js dist/node.cjs",
57+
"build:web": "wasm-pack build --release --no-pack --target web --out-dir dist --out-name web --features std,convert,inspect -Zbuild-std=panic_abort,core,alloc,std",
58+
"build:bundler": "wasm-pack build --release --no-pack --target bundler --out-dir dist --out-name index --features std,convert,inspect -Zbuild-std=panic_abort,core,alloc,std",
59+
"build:minimal": "wasm-pack build --release --no-pack --target bundler --out-dir dist --out-name minimal --features std,default -Zbuild-std=panic_abort,core,alloc,std",
60+
"build:full": "wasm-pack build --release --no-pack --target bundler --out-dir dist --out-name full --features std,convert,split,regex-perf,inspect -Zbuild-std=panic_abort,core,alloc,std",
61+
"build": "cross-env RUSTC_BOOTSTRAP=1 RUSTFLAGS=\"-Ctarget-cpu=mvp -Ctarget-feature=+crt-static,+sign-ext,+bulk-memory,+nontrapping-fptoint,+multivalue,+reference-types -Zwasm-c-abi=spec\" concurrently -m 1 'npm:build:node' 'npm:build:web' 'npm:build:bundler' 'npm:build:minimal' 'npm:build:full'",
62+
"prepare": "cross-env RUSTC_BOOTSTRAP=1 RUSTFLAGS=\"-Ctarget-cpu=mvp -Ctarget-feature=+crt-static,+sign-ext,+bulk-memory,+nontrapping-fptoint,+multivalue,+reference-types -Zwasm-c-abi=spec\" concurrently -m 1 'npm:build:node' 'npm:build:web' 'npm:build:bundler' 'npm:build:minimal' 'npm:build:full'"
6363
},
6464
"devDependencies": {
6565
"concurrently": "^9.1.0",

packages/javascript/src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
#![cfg_attr(not(feature = "std"), no_std)]
1+
#![no_std]
2+
3+
#[cfg(feature = "std")]
4+
extern crate std;
25

36
#[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))]
47
#[global_allocator]
@@ -8,10 +11,9 @@ static ALLOCATOR: rlsf::SmallGlobalTlsf = rlsf::SmallGlobalTlsf::new();
811
extern crate alloc;
912

1013
use alloc::rc::Rc;
14+
use alloc::string::String;
1115
use alloc::vec::Vec;
1216

13-
use core::fmt::{Debug, Display};
14-
1517
use wasm_bindgen::prelude::*;
1618

1719
use ::kitoken::Kitoken as Inner;
@@ -159,6 +161,6 @@ impl Kitoken {
159161
}
160162

161163
#[inline(never)]
162-
fn convert_error(e: impl Display) -> JsValue {
164+
fn convert_error(e: impl core::fmt::Display) -> JsValue {
163165
JsValue::from_str(&format!("{}", e))
164166
}

packages/python/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
name = "kitoken-python"
44
description = "Python bindings for Kitoken"
55
version = "0.10.1"
6-
edition = "2021"
6+
edition = "2024"
77
resolver = "2"
88
publish = false
99
workspace = "../.."
@@ -20,17 +20,17 @@ crate-type = ["cdylib"]
2020

2121
kitoken = { path = "../..", default-features = false, features = ["all"] }
2222

23-
log = { version = "0.4.22" }
24-
pyo3 = { version = "0.23.5", features = [
23+
log = { version = "0.4.27" }
24+
pyo3 = { version = "0.24.2", features = [
2525
"abi3",
2626
"abi3-py310",
2727
"serde",
2828
"extension-module",
2929
"generate-import-lib",
3030
] }
31-
pyo3-log = { version = "0.12.1" }
32-
serde-pyobject = { version = "0.6.0" }
31+
pyo3-log = { version = "0.12.4" }
32+
serde-pyobject = { version = "0.6.1" }
3333

3434
[target.'cfg(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64"))'.dependencies]
3535

36-
mimalloc = { version = "0.1.43", features = ["local_dynamic_tls"] }
36+
mimalloc = { version = "0.1.44", features = ["local_dynamic_tls"] }

src/config.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,10 @@ pub struct Template {
6868

6969
/// Errors returned when the configuration fails to validate.
7070
#[non_exhaustive]
71-
#[derive(Debug)]
72-
#[cfg_attr(feature = "std", derive(thiserror::Error))]
71+
#[derive(Debug, thiserror::Error)]
7372
pub enum ConfigurationError {
7473
/// The feature required for the configuration is not enabled.
75-
#[cfg_attr(feature = "std", error("required feature not enabled: {0}"))]
74+
#[error("required feature not enabled: {0}")]
7675
FeatureDisabled(String),
7776
}
7877

src/config/decoding.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,23 +108,23 @@ impl Decoding {
108108

109109
#[inline(never)]
110110
fn decode_extend(text: &mut Vec<u8>, character: char, left: u32, right: u32, pad: bool) {
111-
let mut buffer = core::iter::repeat(0).take(character.len_utf8()).collect::<Vec<_>>();
111+
let mut buffer = core::iter::repeat_n(0, character.len_utf8()).collect::<Vec<_>>();
112112
character.encode_utf8(&mut buffer);
113113
if left > 0 {
114114
let mut left = left as usize;
115115
if pad {
116116
let leading = text.chars().take(left).take_while(|&c| c == character).count();
117117
left = left.saturating_sub(leading);
118118
}
119-
text.splice(..0, core::iter::repeat(&buffer).take(left).flatten().copied());
119+
text.splice(..0, core::iter::repeat_n(&buffer, left).flatten().copied());
120120
}
121121
if right > 0 {
122122
let mut right = right as usize;
123123
if pad {
124124
let trailing = text.chars().rev().take(right).take_while(|&c| c == character).count();
125125
right = right.saturating_sub(trailing);
126126
}
127-
text.extend(core::iter::repeat(&buffer).take(right).flatten().copied());
127+
text.extend(core::iter::repeat_n(&buffer, right).flatten().copied());
128128
}
129129
}
130130

@@ -200,6 +200,7 @@ fn decode_replace(text: &mut Vec<u8>, pattern: &DecodingReplacePattern, replacem
200200
#[cfg(test)]
201201
mod tests {
202202
use super::*;
203+
use alloc::borrow::ToOwned;
203204
use alloc::vec::Vec;
204205

205206
#[test]

src/config/normalization.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ fn normalize_prepend(text: &mut Cow<str>, prepend: &str) {
236236

237237
#[inline(never)]
238238
fn normalize_extend(text: &mut Cow<str>, character: char, left: u32, right: u32, pad: bool) {
239-
let mut buffer = core::iter::repeat(0).take(character.len_utf8()).collect::<Vec<_>>();
239+
let mut buffer = core::iter::repeat_n(0, character.len_utf8()).collect::<Vec<_>>();
240240
character.encode_utf8(&mut buffer);
241241
if left > 0 {
242242
let mut left = left as usize;
@@ -247,7 +247,7 @@ fn normalize_extend(text: &mut Cow<str>, character: char, left: u32, right: u32,
247247
unsafe {
248248
text.to_mut()
249249
.as_mut_vec()
250-
.splice(..0, core::iter::repeat(&buffer).take(left).flatten().copied());
250+
.splice(..0, core::iter::repeat_n(&buffer, left).flatten().copied());
251251
};
252252
}
253253
if right > 0 {
@@ -259,7 +259,7 @@ fn normalize_extend(text: &mut Cow<str>, character: char, left: u32, right: u32,
259259
unsafe {
260260
text.to_mut()
261261
.as_mut_vec()
262-
.extend(core::iter::repeat(&buffer).take(right).flatten().copied());
262+
.extend(core::iter::repeat_n(&buffer, right).flatten().copied());
263263
};
264264
}
265265
}

src/config/processing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ fn process_pad(
129129
length - len
130130
};
131131
if amount > 0 {
132-
let padding = core::iter::repeat(id).take(amount).collect::<Vec<_>>();
132+
let padding = core::iter::repeat_n(id, amount).collect::<Vec<_>>();
133133
match direction {
134134
ProcessingDirection::Left => {
135135
tokens.splice(0..0, padding);

0 commit comments

Comments
 (0)