Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-lsp-types/src/lib.rs')
| -rw-r--r-- | helix-lsp-types/src/lib.rs | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/helix-lsp-types/src/lib.rs b/helix-lsp-types/src/lib.rs index 5024f6e7..c7b4f0f1 100644 --- a/helix-lsp-types/src/lib.rs +++ b/helix-lsp-types/src/lib.rs @@ -42,9 +42,8 @@ const RESERVED: &percent_encoding::AsciiSet = &percent_encoding::CONTROLS .add(b'='); impl Url { - #[allow(clippy::result_unit_err)] #[cfg(any(unix, target_os = "redox", target_os = "wasi"))] - pub fn from_file_path<P: AsRef<Path>>(path: P) -> Result<Self, ()> { + pub fn from_file_path<P: AsRef<Path>>(path: P) -> Self { #[cfg(any(unix, target_os = "redox"))] use std::os::unix::prelude::OsStrExt; #[cfg(target_os = "wasi")] @@ -63,18 +62,16 @@ impl Url { // An URL's path must not be empty. serialization.push('/'); } - Ok(Self(serialization)) + Self(serialization) } - #[allow(clippy::result_unit_err)] #[cfg(windows)] - pub fn from_file_path<P: AsRef<Path>>(path: P) -> Result<Self, ()> { + pub fn from_file_path<P: AsRef<Path>>(path: P) -> Self { from_file_path_windows(path.as_ref()) } - #[allow(clippy::result_unit_err)] #[cfg_attr(not(windows), allow(dead_code))] - fn from_file_path_windows(path: &Path) -> Result<Self, ()> { + fn from_file_path_windows(path: &Path) -> Self { use std::path::{Component, Prefix}; fn is_windows_drive_letter(segment: &str) -> bool { @@ -123,16 +120,15 @@ impl Url { serialization.push('/'); } - Ok(Self(serialization)) + Self(serialization) } - #[allow(clippy::result_unit_err)] - pub fn from_directory_path<P: AsRef<Path>>(path: P) -> Result<Self, ()> { - let Self(mut serialization) = Self::from_file_path(path)?; + pub fn from_directory_path<P: AsRef<Path>>(path: P) -> Self { + let Self(mut serialization) = Self::from_file_path(path); if !serialization.ends_with('/') { serialization.push('/'); } - Ok(Self(serialization)) + Self(serialization) } /// Returns the serialized representation of the URL as a `&str` |