Skip to content

Commit 8f92490

Browse files
committed
make it easier to conditionally use a backtrace
1 parent b986c86 commit 8f92490

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/error.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,13 @@ impl Error {
7171
///
7272
/// [tracking]: https://github.com/rust-lang/rust/issues/53487
7373
#[cfg(backtrace)]
74-
pub fn backtrace(&self) -> &std::backtrace::Backtrace {
75-
self.error.backtrace()
74+
pub fn backtrace(&self) -> Option<&std::backtrace::Backtrace> {
75+
Some(self.error.backtrace())
76+
}
77+
78+
#[cfg(not(backtrace))]
79+
pub fn backtrace(&self) -> Option<()> {
80+
None
7681
}
7782

7883
/// Attempt to downcast the error object to a concrete type.

0 commit comments

Comments
 (0)