From 0c8e06d588038ae6e24d1898bd33b3ee5a938640 Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Tue, 1 Sep 2020 20:25:26 -0700 Subject: Initial. --- src/error.rs | 24 ++++++++++++++++++++++++ src/main.rs | 25 +++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/error.rs create mode 100644 src/main.rs (limited to 'src') 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 = std::result::Result; + + +fn main() -> Result<()> { + std::process::exit(match repl() { + Ok(()) => 0, + Err(ref e) => { + eprintln!("{}", e); + 1 + } + }) +} + + +fn repl() -> Result<()> { + println!("Hello, terminal!"); + + Ok(()) +} + -- cgit 1.4.1