From db31e770be89cc3e693ffef470878267efeff406 Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Mon, 28 Dec 2020 16:29:24 -0800 Subject: the which builtin now sorta works. yay! --- src/path/error.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/path/error.rs (limited to 'src/path') diff --git a/src/path/error.rs b/src/path/error.rs new file mode 100644 index 0000000..1162a3b --- /dev/null +++ b/src/path/error.rs @@ -0,0 +1,35 @@ +#[derive(Clone,Debug,Eq,Hash,Ord,PartialEq,PartialOrd)] +pub enum FileNameError { + ContainsSlash(String), +} + +#[derive(Clone,Debug,Eq,Hash,Ord,PartialEq,PartialOrd)] +pub enum DirectoryNameError { + ContainsSlash(String), +} + + +impl std::error::Error for FileNameError { } + +impl std::error::Error for DirectoryNameError { } + +impl std::fmt::Display for FileNameError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FileNameError::ContainsSlash(s) => + f.write_fmt(format_args!( + "File names cannot contain slashes, but {:?} does.", s)), + } + } +} + +impl std::fmt::Display for DirectoryNameError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + DirectoryNameError::ContainsSlash(s) => + f.write_fmt(format_args!( + "File names cannot contain slashes, but {:?} does.", s)), + } + } +} + -- cgit 1.4.1