From e5b813b5665a79db92889267b86664c33fcbad64 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 11 Sep 2021 18:42:38 +0300 Subject: [PATCH] minor: improve readability It's important that module interface doesn't depend on features. Better hide features in bodies. --- crates/stdx/src/lib.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs index e83d5db437d..e7d4753de00 100644 --- a/crates/stdx/src/lib.rs +++ b/crates/stdx/src/lib.rs @@ -19,13 +19,11 @@ pub fn timeit(label: &'static str) -> impl Drop { } /// Prints backtrace to stderr, useful for debugging. -#[cfg(feature = "backtrace")] -pub fn print_backtrace() { - let bt = backtrace::Backtrace::new(); - eprintln!("{:?}", bt); -} -#[cfg(not(feature = "backtrace"))] pub fn print_backtrace() { + #[cfg(feature = "backtrace")] + eprintln!("{:?}", backtrace::Backtrace::new()); + + #[cfg(not(feature = "backtrace"))] eprintln!( r#"Enable the backtrace feature. Uncomment `default = [ "backtrace" ]` in `crates/stdx/Cargo.toml`.