Skip to content

Commit 52a29a0

Browse files
committed
fix: rm extra indentation and use byte comparison
1 parent c77a68a commit 52a29a0

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

library/std/src/panic.rs

+18-20
Original file line numberDiff line numberDiff line change
@@ -498,26 +498,24 @@ pub fn get_backtrace_style() -> Option<BacktraceStyle> {
498498
// to optimize away callers.
499499
return None;
500500
}
501-
BacktraceStyle::from_u8(SHOULD_CAPTURE.load(Ordering::Acquire)).map(Some).unwrap_or_else(|| {
502-
let env_var = crate::env::var_os("RUST_BACKTRACE");
503-
let style = env_var
504-
.and_then(|var| {
505-
var.to_str().map(|s| match s {
506-
"0" => BacktraceStyle::Off,
507-
"full" => BacktraceStyle::Full,
508-
_ => BacktraceStyle::Short,
509-
})
510-
})
511-
.unwrap_or_else(|| {
512-
if crate::sys::FULL_BACKTRACE_DEFAULT {
513-
BacktraceStyle::Full
514-
} else {
515-
BacktraceStyle::Short
516-
}
517-
});
518-
set_backtrace_style(style);
519-
Some(style)
520-
})
501+
if let Some(style) = BacktraceStyle::from_u8(SHOULD_CAPTURE.load(Ordering::Acquire)) {
502+
return Some(style);
503+
}
504+
505+
let format = match crate::env::var_os("RUST_BACKTRACE") {
506+
Some(x) if &x == "0" => BacktraceStyle::Off,
507+
Some(x) if &x == "full" => BacktraceStyle::Full,
508+
Some(_) => BacktraceStyle::Short,
509+
None => {
510+
if crate::sys::FULL_BACKTRACE_DEFAULT {
511+
BacktraceStyle::Full
512+
} else {
513+
BacktraceStyle::Short
514+
}
515+
}
516+
};
517+
set_backtrace_style(format);
518+
Some(format)
521519
}
522520

523521
#[cfg(test)]

0 commit comments

Comments
 (0)