diff options
Diffstat (limited to 'src/path.rs')
-rw-r--r-- | src/path.rs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/path.rs b/src/path.rs index 570b8ef..7df10b2 100644 --- a/src/path.rs +++ b/src/path.rs @@ -6,14 +6,15 @@ * to get the benefit of its functionality for handling non-Unicode filenames. */ -use crate::prelude::*; -use crate::path::error::*; +#![forbid(unsafe_code)] +use crate::path::prelude::*; use std::str::FromStr; lalrpop_mod!(pub parser, "/path/parser.rs"); pub mod error; +pub mod prelude; #[derive(Clone,Debug,Eq,Hash,Ord,PartialEq,PartialOrd)] @@ -230,10 +231,10 @@ pub fn parse_path_list(path_list: &str) .parse(path_list) { Ok(_) => { - Err(Error::PathListHasEmptyComponents(path_list.to_string())) + Err(PathError::PathListHasEmptyComponents(path_list.to_string())) }, Err(_) => { - Err(Error::Parse(original_error.to_string())) + Err(PathError::Parse(original_error.to_string())) }, } }, @@ -245,7 +246,7 @@ pub fn absolute_directory_path(generic_path: GenericPath) -> Result<AbsoluteDirectoryPath> { if !generic_path.starts_with_slash { - return Err(Error::PathLexicallyRelative(generic_path)); + return Err(PathError::PathLexicallyRelative(generic_path)); } let mut flattened_components = Vec::new(); @@ -256,7 +257,7 @@ pub fn absolute_directory_path(generic_path: GenericPath) if flattened_components.len() > 0 { flattened_components.pop(); } else { - return Err(Error::PathLexicallyInvalid(generic_path)); + return Err(PathError::PathLexicallyInvalid(generic_path)); } }, GenericPathComponent::FileOrDirectoryName(name) => { @@ -275,11 +276,11 @@ pub fn absolute_file_path(generic_path: GenericPath) -> Result<AbsoluteFilePath> { if !generic_path.starts_with_slash { - return Err(Error::PathLexicallyRelative(generic_path)); + return Err(PathError::PathLexicallyRelative(generic_path)); } if generic_path.ends_with_slash { - return Err(Error::PathLexicallyDirectory(generic_path)); + return Err(PathError::PathLexicallyDirectory(generic_path)); } let mut iterator = generic_path.components.iter(); @@ -289,7 +290,7 @@ pub fn absolute_file_path(generic_path: GenericPath) FileName(name.to_string()) } _ => { - return Err(Error::PathLexicallyInvalid(generic_path)); + return Err(PathError::PathLexicallyInvalid(generic_path)); } }; @@ -301,7 +302,7 @@ pub fn absolute_file_path(generic_path: GenericPath) if flattened_components.len() > 0 { flattened_components.pop(); } else { - return Err(Error::PathLexicallyInvalid(generic_path)); + return Err(PathError::PathLexicallyInvalid(generic_path)); } }, GenericPathComponent::FileOrDirectoryName(name) => { |