Skip to content

Commit e4efb2e

Browse files
committed
chore: Update to edition 2024 in bindings
Signed-off-by: Dmitry Dygalo <dmitry@dygalo.dev>
1 parent aa54481 commit e4efb2e

14 files changed

Lines changed: 34 additions & 32 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ jobs:
757757
sh -c '
758758
set -e
759759
apk add --no-cache alpine-sdk curl gcompat clang clang-dev llvm-dev
760-
curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.83.0
760+
curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.85.0
761761
source ~/.cargo/env
762762
gem update --system
763763
cd bindings/ruby

bindings/c/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "css-inline-c"
33
version = "0.18.0"
44
authors = ["Dmitry Dygalo <dmitry@dygalo.dev>"]
5-
edition = "2021"
5+
edition = "2024"
66

77
[lib]
88
name = "css_inline"

bindings/c/src/lib.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub struct StylesheetCache {
6868

6969
/// @brief Creates an instance of StylesheetCache.
7070
/// @return a StylesheetCache struct
71-
#[no_mangle]
71+
#[unsafe(no_mangle)]
7272
pub extern "C" fn css_inliner_stylesheet_cache(size: size_t) -> StylesheetCache {
7373
StylesheetCache { size }
7474
}
@@ -102,7 +102,7 @@ pub struct CssInlinerOptions {
102102
macro_rules! inliner {
103103
($options:expr) => {
104104
CSSInliner::new(
105-
match InlineOptions::try_from(match $options.as_ref() {
105+
match InlineOptions::try_from(match unsafe { $options.as_ref() } {
106106
Some(ptr) => ptr,
107107
None => return CssResult::NullOptions,
108108
}) {
@@ -115,7 +115,7 @@ macro_rules! inliner {
115115

116116
macro_rules! to_str {
117117
($input:expr) => {
118-
match CStr::from_ptr($input).to_str() {
118+
match unsafe { CStr::from_ptr($input) }.to_str() {
119119
Ok(val) => val,
120120
Err(_) => return CssResult::InvalidInputString,
121121
}
@@ -130,7 +130,7 @@ macro_rules! to_str {
130130
/// @return a CSS_RESULT enum variant regarding if the operation was a success or an error occurred
131131
#[allow(clippy::missing_safety_doc)]
132132
#[must_use]
133-
#[no_mangle]
133+
#[unsafe(no_mangle)]
134134
pub unsafe extern "C" fn css_inline_to(
135135
options: *const CssInlinerOptions,
136136
input: *const c_char,
@@ -144,8 +144,10 @@ pub unsafe extern "C" fn css_inline_to(
144144
return e.into();
145145
};
146146
// Null terminate the pointer
147-
let ptr: *mut c_char = buffer.buffer.add(buffer.pos);
148-
*ptr = 0;
147+
unsafe {
148+
let ptr: *mut c_char = buffer.buffer.add(buffer.pos);
149+
*ptr = 0;
150+
}
149151
CssResult::Ok
150152
}
151153

@@ -158,7 +160,7 @@ pub unsafe extern "C" fn css_inline_to(
158160
/// @return a CSS_RESULT enum variant regarding if the operation was a success or an error occurred
159161
#[allow(clippy::missing_safety_doc)]
160162
#[must_use]
161-
#[no_mangle]
163+
#[unsafe(no_mangle)]
162164
pub unsafe extern "C" fn css_inline_fragment_to(
163165
options: *const CssInlinerOptions,
164166
input: *const c_char,
@@ -174,14 +176,16 @@ pub unsafe extern "C" fn css_inline_fragment_to(
174176
return e.into();
175177
};
176178
// Null terminate the pointer
177-
let ptr: *mut c_char = buffer.buffer.add(buffer.pos);
178-
*ptr = 0;
179+
unsafe {
180+
let ptr: *mut c_char = buffer.buffer.add(buffer.pos);
181+
*ptr = 0;
182+
}
179183
CssResult::Ok
180184
}
181185

182186
/// @brief Creates an instance of CssInlinerOptions with the default parameters.
183187
/// @return a CssInlinerOptions struct
184-
#[no_mangle]
188+
#[unsafe(no_mangle)]
185189
pub extern "C" fn css_inliner_default_options() -> CssInlinerOptions {
186190
CssInlinerOptions {
187191
inline_style_tags: true,

bindings/javascript/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "css-inline-js"
33
version = "0.18.0"
44
authors = ["Dmitry Dygalo <dmitry@dygalo.dev>"]
5-
edition = "2021"
5+
edition = "2024"
66
readme = "README.md"
77
description = "High-performance library for inlining CSS into HTML 'style' attributes"
88
repository = "https://github.com/Stranger6667/css-inline"

bindings/javascript/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#[cfg(not(target_arch = "wasm32"))]
22
use napi_derive::napi;
33
#[cfg(target_arch = "wasm32")]
4-
use wasm_bindgen::prelude::{wasm_bindgen, JsValue};
4+
use wasm_bindgen::prelude::{JsValue, wasm_bindgen};
55

66
mod errors;
77
mod options;

bindings/javascript/src/options.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,11 @@ impl TryFrom<Options> for css_inline::InlineOptions<'_> {
111111
impl css_inline::StylesheetResolver for UnsupportedResolver {
112112
fn retrieve(&self, location: &str) -> css_inline::Result<String> {
113113
let message = if location.starts_with("https")
114-
| location.starts_with("http")
114+
|| location.starts_with("http")
115115
{
116-
format!("Loading remote stylesheets is not supported on WASM: {location}")
116+
format!(
117+
"Loading remote stylesheets is not supported on WASM: {location}"
118+
)
117119
} else {
118120
format!("Loading local files is not supported on WASM: {location}")
119121
};

bindings/php/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "css_inline"
33
version = "0.18.0"
4-
edition = "2021"
4+
edition = "2024"
55
authors = ["Dmitry Dygalo <dmitry@dygalo.dev>"]
66

77
[lib]

bindings/php/src/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,8 @@ impl CssInliner {
8181
None
8282
};
8383

84-
let stylesheet_cache = if let Some(cache) = cache {
85-
Some(Mutex::new(css_inline::StylesheetCache::new(cache.size)))
86-
} else {
87-
None
88-
};
84+
let stylesheet_cache =
85+
cache.map(|cache| Mutex::new(css_inline::StylesheetCache::new(cache.size)));
8986

9087
#[allow(clippy::cast_sign_loss)]
9188
let options = css_inline::InlineOptions {

bindings/python/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
name = "css-inline-python"
33
version = "0.18.0"
44
authors = ["Dmitry Dygalo <dmitry@dygalo.dev>"]
5-
edition = "2021"
6-
rust-version = "1.80"
5+
edition = "2024"
6+
rust-version = "1.85"
77
include = ["src/lib.rs", "README.md", "CHANGELOG.md", "build.rs"]
88

99
[lib]

bindings/ruby/ext/css_inline/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
name = "css-inline-ruby"
33
version = "0.18.0"
44
authors = ["Dmitry Dygalo <dmitry@dygalo.dev>"]
5-
edition = "2021"
5+
edition = "2024"
66
readme = "README.rdoc"
77
description = "High-performance library for inlining CSS into HTML 'style' attributes"
88
repository = "https://github.com/Stranger6667/css-inline"
99
keywords = ["css", "html", "email", "stylesheet", "inlining"]
1010
categories = ["web-programming"]
1111
license = "MIT"
12-
rust-version = "1.83"
12+
rust-version = "1.85"
1313

1414
[lib]
1515
name = "css_inline"

0 commit comments

Comments
 (0)