diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/jt2.rs | 9 | ||||
-rw-r--r-- | src/cmd.rs | 4 | ||||
-rw-r--r-- | src/config.rs | 2 | ||||
-rw-r--r-- | src/journal.rs | 11 |
4 files changed, 12 insertions, 14 deletions
diff --git a/src/bin/jt2.rs b/src/bin/jt2.rs index a8fe6c1..c37b799 100644 --- a/src/bin/jt2.rs +++ b/src/bin/jt2.rs @@ -4,12 +4,9 @@ use jt2::opt::{Opt, SubCommand}; use structopt::StructOpt; fn main() { - match do_work() { - Err(err) => { - eprintln!("ERROR: {:?}", err); - std::process::exit(1); - } - Ok(_) => (), + if let Err(err) = do_work() { + eprintln!("ERROR: {:?}", err); + std::process::exit(1); } } @@ -36,7 +36,9 @@ pub struct IsJournal {} impl IsJournal { pub fn run(&self, config: &Configuration) -> Result<(), JournalError> { if !Journal::is_journal(&config.dirname, &config.entries) { - return Err(JournalError::NotAJournal(config.dirname.display().to_string()).into()); + return Err(JournalError::NotAJournal( + config.dirname.display().to_string(), + )); } Ok(()) } diff --git a/src/config.rs b/src/config.rs index e40c35f..655b835 100644 --- a/src/config.rs +++ b/src/config.rs @@ -28,7 +28,7 @@ impl InputConfiguration { .map_err(|err| JournalError::ReadConfig(filename.to_path_buf(), err))?; let config = serde_yaml::from_slice(&text) .map_err(|err| JournalError::ConfigSyntax(filename.to_path_buf(), err))?; - return Ok(config); + Ok(config) } } diff --git a/src/journal.rs b/src/journal.rs index 2610a44..8042f83 100644 --- a/src/journal.rs +++ b/src/journal.rs @@ -105,19 +105,19 @@ impl Journal { return Ok(pathname); } } - return Err(JournalError::TooManyDrafts( + Err(JournalError::TooManyDrafts( MAX_DRAFT_COUNT, dirname.to_path_buf(), - )); + )) } pub fn pick_draft(&self, id: &str) -> Result<PathBuf, JournalError> { let drafts = self.drafts(); let filename = drafts.join(format!("{}.md", id)); if filename.exists() { - return Ok(filename); + Ok(filename) } else { - return Err(JournalError::NoSuchDraft(id.to_string(), self.drafts())); + Err(JournalError::NoSuchDraft(id.to_string(), self.drafts())) } } @@ -206,7 +206,6 @@ fn topic_path(dirname: &Path, topic: &Path) -> PathBuf { } fn current_timestamp() -> String { - let now = Local::now(); - let now: DateTime<Local> = DateTime::from(now); + let now: DateTime<Local> = Local::now(); now.to_rfc2822() } |