Skip to content
Myr

Merge pull request #280 from dtolnay/contextbacktrace

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

Remove 2 frames of backtrace noise on Option's Context impl

authored by David Tolnay · committed by GitHub · parents 8de29aa, a8649ac · Browse files · 1 file+10 added−2 removed
This commit

State

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

Diff stats

1 file+10 added−2 removed

  • other:+10 added−2 removed

1 file+10 added−2 removed

modified:src/context.rs+10 added-2 removed
90 unmodified lines
91 fn context<C>(self, context: C) -> Result<T, Error>92 where93 C: Display + Send + Sync + 'static,94 {95 self.ok_or_else(|| Error::from_display(context, backtrace!()))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!())),100 }101 }102103 fn with_context<C, F>(self, context: F) -> Result<T, Error>104 where105 C: Display + Send + Sync + 'static,106 F: FnOnce() -> C,107 {103 self.ok_or_else(|| Error::from_display(context(), backtrace!()))108 match self {109 Some(ok) => Ok(ok),110 None => Err(Error::from_display(context(), backtrace!())),111 }112 }113}114115impl<C, E> Debug for ContextError<C, E>
79 unmodified lines