From 13f671b49984ff68ca77e213429f00173b8a6755 Mon Sep 17 00:00:00 2001 From: sharkdp Date: Wed, 22 Apr 2020 21:21:47 +0200 Subject: Update examples --- examples/advanced.rs | 5 +---- examples/simple.rs | 5 +---- src/pretty_printer.rs | 4 ++-- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/examples/advanced.rs b/examples/advanced.rs index 1c4685e7..0c831fcf 100644 --- a/examples/advanced.rs +++ b/examples/advanced.rs @@ -1,10 +1,7 @@ /// A program that prints its own source code using the bat library use bat::{LineRange, PrettyPrinter, WrappingMode}; -use std::ffi::OsStr; fn main() { - let path_to_this_file = OsStr::new(file!()); - PrettyPrinter::new() .header(true) .grid(true) @@ -14,7 +11,7 @@ fn main() { .highlight(LineRange::new(line!() as usize, line!() as usize)) .theme("1337") .wrapping_mode(WrappingMode::Character) - .input_file(path_to_this_file) + .input_file(file!()) .print() .expect("no errors"); } diff --git a/examples/simple.rs b/examples/simple.rs index 8459c6ab..b7217d60 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -1,12 +1,9 @@ /// A simple program that prints its own source code using the bat library use bat::PrettyPrinter; -use std::ffi::OsStr; fn main() { - let path_to_this_file = OsStr::new(file!()); - PrettyPrinter::new() - .input_file(path_to_this_file) + .input_file(file!()) .print() .expect("no errors"); } diff --git a/src/pretty_printer.rs b/src/pretty_printer.rs index 188a48de..db64292b 100644 --- a/src/pretty_printer.rs +++ b/src/pretty_printer.rs @@ -55,8 +55,8 @@ impl<'a> PrettyPrinter<'a> { } /// Add a file which should be pretty-printed - pub fn input_file(&mut self, path: &OsStr) -> &mut Self { - self.inputs.push(Input::ordinary_file(path)); + pub fn input_file(&mut self, path: impl AsRef) -> &mut Self { + self.inputs.push(Input::ordinary_file(path.as_ref())); self } -- cgit v1.2.3