Skip to content

Commit

Permalink
Refactor public interface
Browse files Browse the repository at this point in the history
- Rename `Settings` → `PanicPrinter`
- Make install, format and print functions methods of `PanicPrinter`
- Mostly backwards compatible with deprecation notices
  - Except for `Settings` that previously customized the `out` setting
  • Loading branch information
athre0z committed Apr 30, 2020
1 parent 06b7a2f commit f31fd90
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 166 deletions.
5 changes: 1 addition & 4 deletions examples/custom_message.rs
@@ -1,8 +1,5 @@
fn main() {
use color_backtrace::{default_output_stream, install_with_settings, Settings};
install_with_settings(
Settings::new().message("Custom message!"),
default_output_stream(),
);
install_with_settings(Settings::new().message("Custom message!"));
assert_eq!(1, 2);
}
6 changes: 3 additions & 3 deletions examples/fmt_to_string.rs
@@ -1,9 +1,9 @@
use color_backtrace::{format_backtrace, Settings};
use color_backtrace::PanicPrinter;

fn main() -> Result<(), std::io::Error> {
let trace = backtrace::Backtrace::new();
let settings = Settings::default();
let str = format_backtrace(&trace, &settings)?;
let printer = PanicPrinter::default();
let str = printer.print_trace_to_string(&trace)?;

if cfg!(windows) {
println!(
Expand Down
3 changes: 1 addition & 2 deletions examples/force_color.rs
Expand Up @@ -20,8 +20,7 @@ fn fn1() {

fn main() {
use color_backtrace::{install_with_settings, Settings};
let out = termcolor::StandardStream::stderr(termcolor::ColorChoice::Always);
install_with_settings(Settings::new(), out);
install_with_settings(Settings::new());

fn1();
}
Expand Down

0 comments on commit f31fd90

Please sign in to comment.