Skip to content
Myr

Add construct_ prefix to name of private construct functions

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent 8ceb5e9 · Browse files · 3 files+17 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+17 added−13 removed

  • other:+17 added−13 removed

3 files+17 added−13 removed

modified:src/context.rs+3 added-3 removed
23 unmodified lines
24 where25 C: Display + Send + Sync + 'static,26 {27 let backtrace = backtrace_if_absent!(&self);28 Error::from_context(context, self, backtrace)28 Error::construct_from_context(context, self, backtrace)29 }30 }3132 impl StdError for Error {
62 unmodified lines
95 // Not using ok_or_else to save 2 useless frames off the captured96 // backtrace.97 match self {98 Some(ok) => Ok(ok),99 None => Err(Error::from_display(context, backtrace!())),99 None => Err(Error::construct_from_display(context, backtrace!())),100 }101 }102103 fn with_context<C, F>(self, context: F) -> Result<T, Error>
2 unmodified lines
106 F: FnOnce() -> C,107 {108 match self {109 Some(ok) => Ok(ok),110 None => Err(Error::from_display(context(), backtrace!())),110 None => Err(Error::construct_from_display(context(), backtrace!())),111 }112 }113}114
79 unmodified lines
modified:src/error.rs+12 added-8 removed
34 unmodified lines
35 where36 E: StdError + Send + Sync + 'static,37 {38 let backtrace = backtrace_if_absent!(&error);39 Error::from_std(error, backtrace)39 Error::construct_from_std(error, backtrace)40 }4142 /// Create a new error object from a printable error message.43 ///
37 unmodified lines
81 pub fn msg<M>(message: M) -> Self82 where83 M: Display + Debug + Send + Sync + 'static,84 {85 Error::from_adhoc(message, backtrace!())85 Error::construct_from_adhoc(message, backtrace!())86 }8788 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]89 #[cold]90 pub(crate) fn from_std<E>(error: E, backtrace: Option<Backtrace>) -> Self90 pub(crate) fn construct_from_std<E>(error: E, backtrace: Option<Backtrace>) -> Self91 where92 E: StdError + Send + Sync + 'static,93 {94 let vtable = &ErrorVTable {
17 unmodified lines
112 unsafe { Error::construct(error, vtable, backtrace) }113 }114115 #[cold]116 pub(crate) fn from_adhoc<M>(message: M, backtrace: Option<Backtrace>) -> Self116 pub(crate) fn construct_from_adhoc<M>(message: M, backtrace: Option<Backtrace>) -> Self117 where118 M: Display + Debug + Send + Sync + 'static,119 {120 use crate::wrapper::MessageError;
20 unmodified lines
141 unsafe { Error::construct(error, vtable, backtrace) }142 }143144 #[cold]145 pub(crate) fn from_display<M>(message: M, backtrace: Option<Backtrace>) -> Self145 pub(crate) fn construct_from_display<M>(message: M, backtrace: Option<Backtrace>) -> Self146 where147 M: Display + Send + Sync + 'static,148 {149 use crate::wrapper::DisplayError;
21 unmodified lines
171 }172173 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]174 #[cold]175 pub(crate) fn from_context<C, E>(context: C, error: E, backtrace: Option<Backtrace>) -> Self175 pub(crate) fn construct_from_context<C, E>(176 context: C,177 error: E,178 backtrace: Option<Backtrace>,179 ) -> Self180 where181 C: Display + Send + Sync + 'static,182 E: StdError + Send + Sync + 'static,183 {
21 unmodified lines
205 }206207 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]208 #[cold]205 pub(crate) fn from_boxed(209 pub(crate) fn construct_from_boxed(210 error: Box<dyn StdError + Send + Sync>,211 backtrace: Option<Backtrace>,212 ) -> Self {213 use crate::wrapper::BoxedError;
351 unmodified lines
565{566 #[cold]567 fn from(error: E) -> Self {568 let backtrace = backtrace_if_absent!(&error);565 Error::from_std(error, backtrace)569 Error::construct_from_std(error, backtrace)570 }571}572573#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
458 unmodified lines
modified:src/kind.rs+2 added-2 removed
68 unmodified lines
69 pub fn new<M>(self, message: M) -> Error70 where71 M: Display + Debug + Send + Sync + 'static,72 {73 Error::from_adhoc(message, backtrace!())73 Error::construct_from_adhoc(message, backtrace!())74 }75}7677pub struct Trait;
37 unmodified lines
115impl Boxed {116 #[cold]117 pub fn new(self, error: Box<dyn StdError + Send + Sync>) -> Error {118 let backtrace = backtrace_if_absent!(&*error);119 Error::from_boxed(error, backtrace)119 Error::construct_from_boxed(error, backtrace)120 }121}