Skip to content

Commit

Permalink
Apply clippy suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
wezm committed Mar 25, 2024
1 parent b898b04 commit de83a0b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn parse_args() -> Result<Option<Config>, Error> {
})
})
})
.ok_or_else(|| "unable to determine home directory")?;
.ok_or("unable to determine home directory")?;

Ok(Some(Config {
dry_run,
Expand Down
8 changes: 4 additions & 4 deletions src/grab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::Error;
const HTTPS: &str = "https://";

pub fn grab(home: &Path, url: OsString, dry_run: bool, git_args: &[OsString]) -> Result<(), Error> {
let str = url.to_str().ok_or_else(|| "invalid url")?;
let str = url.to_str().ok_or("invalid url")?;
let url: Url = parse_url(str)?;

let dest_path = clone_path(home, &url)?;
Expand All @@ -23,7 +23,7 @@ pub fn grab(home: &Path, url: OsString, dry_run: bool, git_args: &[OsString]) ->
let status = clone(&url, &dest_path, git_args)?;
status
.success()
.then(|| ())
.then_some(())
.ok_or_else(|| match status.code() {
Some(code) => format!("git exited with status {}", code),
None => String::from("git killed by signal"),
Expand Down Expand Up @@ -65,9 +65,9 @@ fn clone(url: &Url, dest_path: &Path, extra_args: &[OsString]) -> Result<ExitSta

fn clone_path(home: &Path, url: &Url) -> Result<PathBuf, Error> {
let mut path = home.to_path_buf();
path.push(url.host_str().ok_or_else(|| "invalid hostname")?);
path.push(url.host_str().ok_or("invalid hostname")?);
url.path_segments()
.ok_or_else(|| "missing path in url")?
.ok_or("missing path in url")?
.for_each(|seg| path.push(seg));

// Strip trailing .git from clone path
Expand Down

0 comments on commit de83a0b

Please sign in to comment.