Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: Address warnings #319

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ struct StyledValue<T> {

#[cfg(feature = "color")]
impl<T: Display> Display for StyledValue<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let style = self.style;

// We need to make sure `f`s settings don't get passed onto the styling but do get passed
Expand Down
8 changes: 4 additions & 4 deletions src/fmt/writer/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl BufferWriter {
let buf = buf.as_bytes();
match &self.target {
WritableTarget::WriteStdout => {
let stream = std::io::stdout();
let stream = io::stdout();
#[cfg(feature = "color")]
let stream = anstream::AutoStream::new(stream, self.write_style.into());
let mut stream = stream.lock();
Expand All @@ -74,7 +74,7 @@ impl BufferWriter {
print!("{}", buf);
}
WritableTarget::WriteStderr => {
let stream = std::io::stderr();
let stream = io::stderr();
#[cfg(feature = "color")]
let stream = anstream::AutoStream::new(stream, self.write_style.into());
let mut stream = stream.lock();
Expand Down Expand Up @@ -105,7 +105,7 @@ impl BufferWriter {
}

#[cfg(feature = "color")]
fn adapt(buf: &[u8], write_style: WriteStyle) -> std::io::Result<Vec<u8>> {
fn adapt(buf: &[u8], write_style: WriteStyle) -> io::Result<Vec<u8>> {
use std::io::Write as _;

let adapted = Vec::with_capacity(buf.len());
Expand Down Expand Up @@ -155,7 +155,7 @@ pub(super) enum WritableTarget {
/// Logs will be printed to standard error.
PrintStderr,
/// Logs will be sent to a custom pipe.
Pipe(Box<Mutex<dyn std::io::Write + Send + 'static>>),
Pipe(Box<Mutex<dyn io::Write + Send + 'static>>),
}

impl std::fmt::Debug for WritableTarget {
Expand Down
4 changes: 2 additions & 2 deletions src/fmt/writer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ impl Builder {
#[cfg(feature = "auto-color")]
let color_choice = if color_choice == WriteStyle::Auto {
match &self.target {
Target::Stdout => anstream::AutoStream::choice(&std::io::stdout()).into(),
Target::Stderr => anstream::AutoStream::choice(&std::io::stderr()).into(),
Target::Stdout => anstream::AutoStream::choice(&io::stdout()).into(),
Target::Stderr => anstream::AutoStream::choice(&io::stderr()).into(),
Target::Pipe(_) => color_choice,
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ impl Builder {
/// [`Formatter`]: fmt/struct.Formatter.html
/// [`String`]: https://doc.rust-lang.org/stable/std/string/struct.String.html
/// [`std::fmt`]: https://doc.rust-lang.org/std/fmt/index.html
pub fn format<F: 'static>(&mut self, format: F) -> &mut Self
pub fn format<F>(&mut self, format: F) -> &mut Self
where
F: Fn(&mut Formatter, &Record<'_>) -> io::Result<()> + Sync + Send,
F: Fn(&mut Formatter, &Record<'_>) -> io::Result<()> + Sync + Send + 'static,
{
self.format.custom_format = Some(Box::new(format));
self
Expand Down
Loading