Skip to content

Commit 37f4014

Browse files
committed
feat: upgrade to rust 2024
1 parent 9927823 commit 37f4014

File tree

11 files changed

+68
-36
lines changed

11 files changed

+68
-36
lines changed

crates/Cargo.lock

Lines changed: 39 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/abi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "abi"
33
version = "0.0.0"
4-
edition = "2021"
4+
edition = "2024"
55
publish = false
66

77
[dependencies]

crates/abi/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
//! C/C++ application binary interface of the library.
22
3+
#![allow(unsafe_op_in_unsafe_fn)]
4+
35
mod models;
46

57
use models::*;
68
use sprite_dicing::{
79
Artifacts, DicedSprite, Error, Pivot, Pixel, Prefs, Progress, Rect, SourceSprite, Texture, Uv,
810
Vertex,
911
};
10-
use std::ffi::{c_char, CStr, CString};
12+
use std::ffi::{CStr, CString, c_char};
1113
use std::mem;
1214

1315
/// C ABI wrapper over [sprite_dicing::dice].
1416
///
1517
/// # Safety
1618
///
1719
/// Returned [CSlice]-governed memory is expected to be de-allocated by the caller.
18-
#[no_mangle]
20+
#[unsafe(no_mangle)]
1921
pub unsafe extern "C" fn dice(sprites: CSlice<CSourceSprite>, prefs: CPrefs) -> CResult {
2022
let prefs = to_prefs(prefs);
2123
let sprites: Vec<_> = to_slice(sprites).iter().map(|s| to_sprite(s)).collect();

crates/cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "cli"
33
version = "0.0.0"
4-
edition = "2021"
4+
edition = "2024"
55
publish = false
66

77
[dependencies]

crates/cli/src/models.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ pub enum Error {
1818
impl std::fmt::Display for Error {
1919
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2020
match self {
21-
Error::Dicing(info) => write!(f, "{}", info),
22-
Error::Image(err) => write!(f, "{}", err),
23-
Error::Io(err) => write!(f, "{}", err),
21+
Error::Dicing(info) => write!(f, "{info}"),
22+
Error::Image(err) => write!(f, "{err}"),
23+
Error::Io(err) => write!(f, "{err}"),
2424
}
2525
}
2626
}

crates/lib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "sprite_dicing"
33
version = "0.1.4"
4-
edition = "2021"
4+
edition = "2024"
55
description = "Cross-engine tool for lossless compression of sprite textures with identical areas."
66
license = "MIT"
77
authors = ["Artyom Sovetnikov (Elringus)"]

crates/lib/src/dicer.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,18 @@ mod tests {
153153

154154
#[test]
155155
fn errs_when_unit_size_zero() {
156-
assert!(dice(&[src(&R1X1)], &pref(0, 0))
157-
.is_err_and(|e| e.to_string() == "Unit size can't be zero."));
156+
assert!(
157+
dice(&[src(&R1X1)], &pref(0, 0))
158+
.is_err_and(|e| e.to_string() == "Unit size can't be zero.")
159+
);
158160
}
159161

160162
#[test]
161163
fn errs_when_padding_is_above_unit_size() {
162-
assert!(dice(&[src(&R1X1)], &pref(1, 2))
163-
.is_err_and(|e| e.to_string() == "Padding can't be above unit size."));
164+
assert!(
165+
dice(&[src(&R1X1)], &pref(1, 2))
166+
.is_err_and(|e| e.to_string() == "Padding can't be above unit size.")
167+
);
164168
}
165169

166170
#[test]

crates/lib/src/fixtures.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ impl AnySource for (&LazyLock<Texture>, (f32, f32)) {
116116
}
117117
fn pivot(&self) -> Option<Pivot> {
118118
Some(Pivot {
119-
x: self.1 .0,
120-
y: self.1 .1,
119+
x: self.1.0,
120+
y: self.1.1,
121121
})
122122
}
123123
}

crates/lib/src/models.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub enum Error {
1515
impl std::fmt::Display for Error {
1616
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1717
match self {
18-
Error::Spec(info) => write!(f, "{}", info),
18+
Error::Spec(info) => write!(f, "{info}"),
1919
}
2020
}
2121
}

crates/tests/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "tests"
33
version = "0.0.0"
4-
edition = "2021"
4+
edition = "2024"
55
publish = false
66

77
[[test]]
@@ -13,4 +13,4 @@ sprite_dicing = { path = "../lib" }
1313
cli = { path = "../cli" }
1414
image = { version = "0.25", default-features = false, features = ["png", "webp"] }
1515
serde_json = "1.0"
16-
rand = "0.8"
16+
rand = "0.9"

0 commit comments

Comments
 (0)