Skip to content

Commit

Permalink
refactor(mangen): use argument impl over generic
Browse files Browse the repository at this point in the history
  • Loading branch information
EdJoPaTo committed Jan 30, 2024
1 parent 868aa30 commit 749af4e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions clap_mangen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ impl Man {
}

/// [Renders](Man::render) the manual page and writes it to a file
pub fn generate_to<Dir>(&self, out_dir: Dir) -> Result<std::path::PathBuf, std::io::Error>
where
Dir: AsRef<std::path::Path>,
{
pub fn generate_to(
&self,
out_dir: impl AsRef<std::path::Path>,
) -> Result<std::path::PathBuf, std::io::Error> {
let filepath = out_dir.as_ref().join(self.get_filename());
let mut file = std::fs::File::create(&filepath)?;
self.render(&mut file)?;
Expand All @@ -123,10 +123,10 @@ impl Man {
}

/// Generate manual page files for the command with all subcommands
pub fn generate_to<Dir>(cmd: clap::Command, out_dir: Dir) -> Result<(), std::io::Error>
where
Dir: AsRef<std::path::Path>,
{
pub fn generate_to(
cmd: clap::Command,
out_dir: impl AsRef<std::path::Path>,
) -> Result<(), std::io::Error> {
fn generate(cmd: clap::Command, out_dir: &std::path::Path) -> Result<(), std::io::Error> {
for cmd in cmd.get_subcommands().cloned() {
generate(cmd, out_dir)?;
Expand Down

0 comments on commit 749af4e

Please sign in to comment.