mirror of
https://github.com/Hopiu/lychee.git
synced 2026-05-10 06:44:45 +00:00
Introduce new let...else syntax (#936)
This commit is contained in:
parent
06b0f27b74
commit
9837699b79
3 changed files with 12 additions and 21 deletions
|
|
@ -44,9 +44,8 @@ pub(crate) fn resolve(src: &Path, dst: &Path, base: &Option<Base>) -> Result<Opt
|
|||
let resolved = match dst {
|
||||
relative if dst.is_relative() => {
|
||||
// Find `dst` in the parent directory of `src`
|
||||
let parent = match src.parent() {
|
||||
Some(parent) => parent,
|
||||
None => return Err(ErrorKind::FileNotFound(relative.to_path_buf())),
|
||||
let Some(parent) = src.parent() else {
|
||||
return Err(ErrorKind::FileNotFound(relative.to_path_buf()))
|
||||
};
|
||||
parent.join(relative)
|
||||
}
|
||||
|
|
@ -54,18 +53,12 @@ pub(crate) fn resolve(src: &Path, dst: &Path, base: &Option<Base>) -> Result<Opt
|
|||
// Absolute local links (leading slash) require the `base_url` to
|
||||
// define the document root. Silently ignore the link in case the
|
||||
// `base_url` is not defined.
|
||||
let base = match get_base_dir(base) {
|
||||
Some(path) => path,
|
||||
None => return Ok(None),
|
||||
};
|
||||
let dir = match dirname(&base) {
|
||||
Some(dir) => dir,
|
||||
None => {
|
||||
return Err(ErrorKind::InvalidBase(
|
||||
base.display().to_string(),
|
||||
"The given directory cannot be a base".to_string(),
|
||||
))
|
||||
}
|
||||
let Some(base) = get_base_dir(base) else { return Ok(None) };
|
||||
let Some(dir) = dirname(&base) else {
|
||||
return Err(ErrorKind::InvalidBase(
|
||||
base.display().to_string(),
|
||||
"The given directory cannot be a base".to_string(),
|
||||
))
|
||||
};
|
||||
join(dir.to_path_buf(), absolute)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -315,9 +315,8 @@ impl Input {
|
|||
|
||||
/// Check if the given path was excluded from link checking
|
||||
fn is_excluded_path(&self, path: &PathBuf) -> bool {
|
||||
let excluded_paths = match &self.excluded_paths {
|
||||
Some(excluded) => excluded,
|
||||
None => return false,
|
||||
let Some(excluded_paths) = &self.excluded_paths else {
|
||||
return false
|
||||
};
|
||||
is_excluded_path(excluded_paths, path)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,9 +64,8 @@ impl GithubUri {
|
|||
|
||||
debug_assert!(!uri.is_mail(), "Should only be called on a Website type!");
|
||||
|
||||
let domain = match uri.domain() {
|
||||
Some(domain) => domain,
|
||||
None => return Err(ErrorKind::InvalidGithubUrl(uri.to_string())),
|
||||
let Some(domain) = uri.domain() else {
|
||||
return Err(ErrorKind::InvalidGithubUrl(uri.to_string()))
|
||||
};
|
||||
|
||||
if !matches!(
|
||||
|
|
|
|||
Loading…
Reference in a new issue