Merge pull request #1078 from jayvdb/fixup-display

Fix BinaryFile display
This commit is contained in:
Ed Page 2024-08-17 19:25:09 -05:00 committed by GitHub
commit 5bb1eeac23
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 6 additions and 6 deletions

View file

@ -63,7 +63,7 @@ impl Report for PrintBrief {
fn report(&self, msg: Message<'_>) -> Result<(), std::io::Error> { fn report(&self, msg: Message<'_>) -> Result<(), std::io::Error> {
match &msg { match &msg {
Message::BinaryFile(msg) => { Message::BinaryFile(msg) => {
log::info!("{}", msg); log::info!("{msg}");
} }
Message::Typo(msg) => print_brief_correction(msg)?, Message::Typo(msg) => print_brief_correction(msg)?,
Message::FileType(msg) => { Message::FileType(msg) => {
@ -97,7 +97,7 @@ impl Report for PrintLong {
fn report(&self, msg: Message<'_>) -> Result<(), std::io::Error> { fn report(&self, msg: Message<'_>) -> Result<(), std::io::Error> {
match &msg { match &msg {
Message::BinaryFile(msg) => { Message::BinaryFile(msg) => {
log::info!("{}", msg); log::info!("{msg}");
} }
Message::Typo(msg) => print_long_correction(msg)?, Message::Typo(msg) => print_long_correction(msg)?,
Message::FileType(msg) => { Message::FileType(msg) => {

View file

@ -474,7 +474,7 @@ fn read_file(
let (r, written) = encoding_rs::UTF_16LE.new_decoder_with_bom_removal().decode_to_string_without_replacement(&buffer, &mut decoded, true); let (r, written) = encoding_rs::UTF_16LE.new_decoder_with_bom_removal().decode_to_string_without_replacement(&buffer, &mut decoded, true);
let decoded = match r { let decoded = match r {
encoding_rs::DecoderResult::InputEmpty => Ok(decoded), encoding_rs::DecoderResult::InputEmpty => Ok(decoded),
_ => Err(format!("invalid UTF-16LE encoding at byte {} in {}", written, path.display())), _ => Err(format!("invalid UTF-16LE encoding at byte {written} in {}", path.display())),
}; };
let buffer = report_result(decoded, Some(path), reporter)?; let buffer = report_result(decoded, Some(path), reporter)?;
(buffer.into_bytes(), content_type) (buffer.into_bytes(), content_type)
@ -487,7 +487,7 @@ fn read_file(
let (r, written) = encoding_rs::UTF_16BE.new_decoder_with_bom_removal().decode_to_string_without_replacement(&buffer, &mut decoded, true); let (r, written) = encoding_rs::UTF_16BE.new_decoder_with_bom_removal().decode_to_string_without_replacement(&buffer, &mut decoded, true);
let decoded = match r { let decoded = match r {
encoding_rs::DecoderResult::InputEmpty => Ok(decoded), encoding_rs::DecoderResult::InputEmpty => Ok(decoded),
_ => Err(format!("invalid UTF-16BE encoding at byte {} in {}", written, path.display())), _ => Err(format!("invalid UTF-16BE encoding at byte {written} in {}", path.display())),
}; };
let buffer = report_result(decoded, Some(path), reporter)?; let buffer = report_result(decoded, Some(path), reporter)?;
(buffer.into_bytes(), content_type) (buffer.into_bytes(), content_type)

View file

@ -319,7 +319,7 @@ impl DirConfig {
let config = name let config = name
.and_then(|name| { .and_then(|name| {
log::debug!("{}: `{}` policy", path.display(), name); log::debug!("{}: `{name}` policy", path.display());
self.types.get(name).copied() self.types.get(name).copied()
}) })
.unwrap_or_else(|| { .unwrap_or_else(|| {

View file

@ -62,7 +62,7 @@ impl<'m> Message<'m> {
} }
#[derive(Clone, Debug, serde::Serialize, derive_more::Display, derive_setters::Setters)] #[derive(Clone, Debug, serde::Serialize, derive_more::Display, derive_setters::Setters)]
#[display("Skipping binary file {}", "path.display()")] #[display("Skipping binary file {}", path.display())]
#[non_exhaustive] #[non_exhaustive]
pub struct BinaryFile<'m> { pub struct BinaryFile<'m> {
pub path: &'m std::path::Path, pub path: &'m std::path::Path,