From 671f700dd3decdfb56c8f8b6fdae6ced5acd5ca9 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 22 Dec 2024 03:11:30 -0800 Subject: [PATCH] Add construct_ prefix to name of private construct functions --- src/context.rs | 6 +++--- src/error.rs | 20 ++++++++++++-------- src/kind.rs | 4 ++-- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/context.rs b/src/context.rs index b52f682..326c2a4 100644 --- a/src/context.rs +++ b/src/context.rs @@ -25,7 +25,7 @@ mod ext { C: Display + Send + Sync + 'static, { let backtrace = backtrace_if_absent!(&self); - Error::from_context(context, self, backtrace) + Error::construct_from_context(context, self, backtrace) } } @@ -96,7 +96,7 @@ impl Context for Option { // backtrace. match self { Some(ok) => Ok(ok), - None => Err(Error::from_display(context, backtrace!())), + None => Err(Error::construct_from_display(context, backtrace!())), } } @@ -107,7 +107,7 @@ impl Context for Option { { match self { Some(ok) => Ok(ok), - None => Err(Error::from_display(context(), backtrace!())), + None => Err(Error::construct_from_display(context(), backtrace!())), } } } diff --git a/src/error.rs b/src/error.rs index a83eb7e..76369a9 100644 --- a/src/error.rs +++ b/src/error.rs @@ -36,7 +36,7 @@ impl Error { E: StdError + Send + Sync + 'static, { let backtrace = backtrace_if_absent!(&error); - Error::from_std(error, backtrace) + Error::construct_from_std(error, backtrace) } /// Create a new error object from a printable error message. @@ -82,12 +82,12 @@ impl Error { where M: Display + Debug + Send + Sync + 'static, { - Error::from_adhoc(message, backtrace!()) + Error::construct_from_adhoc(message, backtrace!()) } #[cfg(any(feature = "std", not(anyhow_no_core_error)))] #[cold] - pub(crate) fn from_std(error: E, backtrace: Option) -> Self + pub(crate) fn construct_from_std(error: E, backtrace: Option) -> Self where E: StdError + Send + Sync + 'static, { @@ -113,7 +113,7 @@ impl Error { } #[cold] - pub(crate) fn from_adhoc(message: M, backtrace: Option) -> Self + pub(crate) fn construct_from_adhoc(message: M, backtrace: Option) -> Self where M: Display + Debug + Send + Sync + 'static, { @@ -142,7 +142,7 @@ impl Error { } #[cold] - pub(crate) fn from_display(message: M, backtrace: Option) -> Self + pub(crate) fn construct_from_display(message: M, backtrace: Option) -> Self where M: Display + Send + Sync + 'static, { @@ -172,7 +172,11 @@ impl Error { #[cfg(any(feature = "std", not(anyhow_no_core_error)))] #[cold] - pub(crate) fn from_context(context: C, error: E, backtrace: Option) -> Self + pub(crate) fn construct_from_context( + context: C, + error: E, + backtrace: Option, + ) -> Self where C: Display + Send + Sync + 'static, E: StdError + Send + Sync + 'static, @@ -202,7 +206,7 @@ impl Error { #[cfg(any(feature = "std", not(anyhow_no_core_error)))] #[cold] - pub(crate) fn from_boxed( + pub(crate) fn construct_from_boxed( error: Box, backtrace: Option, ) -> Self { @@ -562,7 +566,7 @@ where #[cold] fn from(error: E) -> Self { let backtrace = backtrace_if_absent!(&error); - Error::from_std(error, backtrace) + Error::construct_from_std(error, backtrace) } } diff --git a/src/kind.rs b/src/kind.rs index 042af32..a9f40c3 100644 --- a/src/kind.rs +++ b/src/kind.rs @@ -70,7 +70,7 @@ impl Adhoc { where M: Display + Debug + Send + Sync + 'static, { - Error::from_adhoc(message, backtrace!()) + Error::construct_from_adhoc(message, backtrace!()) } } @@ -116,6 +116,6 @@ impl Boxed { #[cold] pub fn new(self, error: Box) -> Error { let backtrace = backtrace_if_absent!(&*error); - Error::from_boxed(error, backtrace) + Error::construct_from_boxed(error, backtrace) } }