From aa1a22b4dd1df2bf90656b46c3af22b086c2cca6 Mon Sep 17 00:00:00 2001 From: RA <70325462+RAprogramm@users.noreply.github.com> Date: Sat, 27 Sep 2025 19:32:34 +0700 Subject: [PATCH] Fix no_std doc build regressions --- CHANGELOG.md | 10 ++++++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 4 ++-- src/code/app_code.rs | 2 +- src/convert.rs | 3 +++ src/response/details.rs | 3 +++ src/response/legacy.rs | 2 ++ 8 files changed, 23 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bdf5f4f..605fc86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +## [0.24.6] - 2025-10-22 + +### Fixed +- Restored `no_std` builds by importing `alloc::String` for response helpers and + the legacy constructor, keeping textual detail setters available without the + `std` feature. +- Ensured `AppCode::from_str` remains available in `no_std` mode by explicitly + bringing `ToOwned` into scope and gated the `std::io::Error` conversion example + so doctests compile without the standard library. + ## [0.24.5] - 2025-10-21 ### Fixed diff --git a/Cargo.lock b/Cargo.lock index caabbbb..a838efe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1806,7 +1806,7 @@ dependencies = [ [[package]] name = "masterror" -version = "0.24.5" +version = "0.24.6" dependencies = [ "actix-web", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 9ebc1dd..3726d53 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "masterror" -version = "0.24.5" +version = "0.24.6" rust-version = "1.90" edition = "2024" license = "MIT OR Apache-2.0" diff --git a/README.md b/README.md index e5c5538..07b5c3a 100644 --- a/README.md +++ b/README.md @@ -74,9 +74,9 @@ The build script keeps the full feature snippet below in sync with ~~~toml [dependencies] -masterror = { version = "0.24.5", default-features = false } +masterror = { version = "0.24.6", default-features = false } # or with features: -# masterror = { version = "0.24.5", features = [ +# masterror = { version = "0.24.6", features = [ # "std", "axum", "actix", "openapi", # "serde_json", "tracing", "metrics", "backtrace", # "sqlx", "sqlx-migrate", "reqwest", "redis", diff --git a/src/code/app_code.rs b/src/code/app_code.rs index 280d545..5971a3f 100644 --- a/src/code/app_code.rs +++ b/src/code/app_code.rs @@ -1,4 +1,4 @@ -use alloc::{boxed::Box, string::String}; +use alloc::{borrow::ToOwned, boxed::Box, string::String}; use core::{ error::Error as CoreError, fmt::{self, Display}, diff --git a/src/convert.rs b/src/convert.rs index 3915860..374b66a 100644 --- a/src/convert.rs +++ b/src/convert.rs @@ -44,6 +44,8 @@ //! `std::io::Error` mapping: //! //! ```rust +//! # #[cfg(feature = "std")] +//! # { //! use std::io::{self, ErrorKind}; //! //! use masterror::{AppError, AppErrorKind, AppResult}; @@ -55,6 +57,7 @@ //! //! let err = open().unwrap_err(); //! assert!(matches!(err.kind, AppErrorKind::Internal)); +//! # } //! ``` //! //! `String` mapping (useful for ad-hoc validation without the `validator` diff --git a/src/response/details.rs b/src/response/details.rs index f1a05c4..7a9b0f8 100644 --- a/src/response/details.rs +++ b/src/response/details.rs @@ -1,3 +1,6 @@ +#[cfg(not(feature = "serde_json"))] +use alloc::string::String; + #[cfg(feature = "serde_json")] use serde::Serialize; #[cfg(feature = "serde_json")] diff --git a/src/response/legacy.rs b/src/response/legacy.rs index 217e6fd..ce9e3e7 100644 --- a/src/response/legacy.rs +++ b/src/response/legacy.rs @@ -1,3 +1,5 @@ +use alloc::string::String; + use http::StatusCode; use super::core::ErrorResponse;