Skip to content

Commit

Permalink
refactor: use Utf8PathBuf instead of PathBuf
Browse files Browse the repository at this point in the history
  • Loading branch information
loichyan committed Oct 2, 2024
1 parent d060f1a commit b424be4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ rust-version = "1.70"

[dependencies]
bytesize = "1.3"
camino = "1.1"
clap = { version = ">=4.0, <4.5", features = ["derive"] }
codespan-reporting = "0.11.1"
content_inspector = "0.2.4"
Expand Down
6 changes: 3 additions & 3 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//! Command line arguments parser.
use std::io::BufReader;
use std::path::PathBuf;
use std::str::FromStr;
use std::{fmt, fs, io};

use bytesize::ByteSize;
use camino::Utf8PathBuf;
use clap::{Parser, Subcommand, ValueEnum};
use shadow_rs::formatcp;
use thisctx::IntoError;
Expand Down Expand Up @@ -170,7 +170,7 @@ impl FromStr for UserInput {
#[derive(Clone, Debug)]
pub enum IoPath {
Stdio,
Path(PathBuf),
Path(Utf8PathBuf),
}

impl FromStr for IoPath {
Expand All @@ -189,7 +189,7 @@ impl fmt::Display for IoPath {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Stdio => f.write_str("STDIO"),
Self::Path(path) => path.display().fmt(f),
Self::Path(path) => path.fmt(f),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fn walk<'a>(
})
.transpose()
})
.map(|e| e.map(|path| Source(IoPath::Path(path), None))),
.map(|e| e.map(|path| Source(IoPath::Path(path.try_into().unwrap()), None))),
)
}
}
Expand Down

0 comments on commit b424be4

Please sign in to comment.