diff options
author | Irene Knapp <ireneista@gmail.com> | 2020-09-01 20:25:26 -0700 |
---|---|---|
committer | Irene Knapp <ireneista@gmail.com> | 2020-09-01 20:25:26 -0700 |
commit | 0c8e06d588038ae6e24d1898bd33b3ee5a938640 (patch) | |
tree | 74833939e37908366fe2cb71d639dbe641e054a6 /src |
Initial.
Diffstat (limited to 'src')
-rw-r--r-- | src/error.rs | 24 | ||||
-rw-r--r-- | src/main.rs | 25 |
2 files changed, 49 insertions, 0 deletions
diff --git a/src/error.rs b/src/error.rs new file mode 100644 index 0000000..7054551 --- /dev/null +++ b/src/error.rs @@ -0,0 +1,24 @@ +#[derive(Debug)] +pub enum Error { + IO(std::io::Error), +} + +impl std::error::Error for Error { } + +impl std::fmt::Display for Error { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Error::IO(e) => e.fmt(f), + } + } +} + +impl std::cmp::PartialEq for Error { + fn eq(&self, other: &Self) -> bool { + match (self, other) { + (Error::IO(_), Error::IO(_)) => + false, + } + } +} + diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..5ca6d46 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,25 @@ +pub mod error; + +use error::Error; + + +pub type Result<T> = std::result::Result<T, Error>; + + +fn main() -> Result<()> { + std::process::exit(match repl() { + Ok(()) => 0, + Err(ref e) => { + eprintln!("{}", e); + 1 + } + }) +} + + +fn repl() -> Result<()> { + println!("Hello, terminal!"); + + Ok(()) +} + |