From 1b3b38ab5e7d898e74efe2f8a332970b92f40265 Mon Sep 17 00:00:00 2001 From: RA <70325462+RAprogramm@users.noreply.github.com> Date: Tue, 30 Sep 2025 14:59:18 +0700 Subject: [PATCH] Guard std-dependent docs and bump version --- CHANGELOG.md | 7 +++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 5 ++--- src/app_error/context.rs | 2 ++ src/app_error/core.rs | 4 ++++ src/lib.rs | 2 ++ src/response.rs | 2 +- 8 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f05e809..d7087b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +## [0.24.12] - 2025-10-28 + +### Fixed +- Gated documentation examples that rely on the standard library and switched + the `ErrorResponse` retry example to `core::time::Duration` so docs compile + without the `std` feature. + ## [0.24.11] - 2025-10-27 ### Fixed diff --git a/Cargo.lock b/Cargo.lock index 6c9768c..0a9119e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1804,7 +1804,7 @@ dependencies = [ [[package]] name = "masterror" -version = "0.24.11" +version = "0.24.12" dependencies = [ "actix-web", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 445a3ff..4d256e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "masterror" -version = "0.24.11" +version = "0.24.12" rust-version = "1.90" edition = "2024" license = "MIT OR Apache-2.0" diff --git a/README.md b/README.md index b4b24d8..7855cbf 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.11", default-features = false } +masterror = { version = "0.24.12", default-features = false } # or with features: -# masterror = { version = "0.24.11", features = [ +# masterror = { version = "0.24.12", features = [ # "std", "axum", "actix", "openapi", # "serde_json", "tracing", "metrics", "backtrace", # "sqlx", "sqlx-migrate", "reqwest", "redis", @@ -446,4 +446,3 @@ assert_eq!(problem.grpc.expect("grpc").name, "UNAUTHENTICATED"); --- MSRV: **1.90** · License: **MIT OR Apache-2.0** · No `unsafe` - diff --git a/src/app_error/context.rs b/src/app_error/context.rs index 7d20c15..7decde8 100644 --- a/src/app_error/context.rs +++ b/src/app_error/context.rs @@ -17,6 +17,7 @@ use crate::{AppCode, AppErrorKind}; /// # Examples /// /// ```rust +/// # #[cfg(feature = "std")] { /// use std::io::{Error as IoError, ErrorKind}; /// /// use masterror::{AppErrorKind, Context, ResultExt, field}; @@ -36,6 +37,7 @@ use crate::{AppCode, AppErrorKind}; /// /// assert_eq!(err.kind, AppErrorKind::Service); /// assert!(err.metadata().get("operation").is_some()); +/// # } /// ``` #[derive(Debug, Clone)] pub struct Context { diff --git a/src/app_error/core.rs b/src/app_error/core.rs index b329d72..755ac2a 100644 --- a/src/app_error/core.rs +++ b/src/app_error/core.rs @@ -460,11 +460,13 @@ impl Error { /// # Examples /// /// ```rust + /// # #[cfg(feature = "std")] { /// use masterror::AppError; /// /// let err = AppError::service("downstream degraded") /// .with_context(std::io::Error::new(std::io::ErrorKind::Other, "boom")); /// assert!(err.source_ref().is_some()); + /// # } /// ``` #[must_use] pub fn with_context(self, context: impl Into) -> Self { @@ -495,6 +497,7 @@ impl Error { /// # Examples /// /// ```rust + /// # #[cfg(feature = "std")] { /// use std::sync::Arc; /// /// use masterror::{AppError, AppErrorKind}; @@ -503,6 +506,7 @@ impl Error { /// let err = AppError::internal("boom").with_source_arc(source.clone()); /// assert!(err.source_ref().is_some()); /// assert_eq!(Arc::strong_count(&source), 2); + /// # } /// ``` #[must_use] pub fn with_source_arc(mut self, source: Arc) -> Self { diff --git a/src/lib.rs b/src/lib.rs index 178383d..65b89fc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -230,11 +230,13 @@ //! //! Attach upstream diagnostics without cloning existing `Arc`s: //! ```rust +//! # #[cfg(feature = "std")] { //! use masterror::AppError; //! //! let err = AppError::internal("db down") //! .with_context(std::io::Error::new(std::io::ErrorKind::Other, "boom")); //! assert!(err.source_ref().is_some()); +//! # } //! ``` //! //! [`AppErrorKind`] controls the default HTTP status mapping. diff --git a/src/response.rs b/src/response.rs index 5f7d926..1a4c96e 100644 --- a/src/response.rs +++ b/src/response.rs @@ -26,7 +26,7 @@ //! # Example //! //! ```rust -//! use std::time::Duration; +//! use core::time::Duration; //! //! use masterror::{AppCode, ErrorResponse}; //!