From d2d80030c1eaae9f08fb6a51c4159eed009086b6 Mon Sep 17 00:00:00 2001 From: NerdyPepper Date: Sun, 23 Jun 2019 17:16:56 +0530 Subject: remove unused imports, closes #16 and #17 --- src/main.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index d6883d5..10ae251 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,7 +6,8 @@ // std use std::f64; -use std::borrow::Cow::{self, Borrowed, Owned}; +use std::borrow::Cow::{self,Owned}; +use std::path::PathBuf; // modules mod lex; @@ -24,12 +25,11 @@ use rustyline::{ Editor, Context, Helper }; use rustyline::config::{ Builder, ColorMode, EditMode, CompletionType }; use rustyline::hint::Hinter; use rustyline::completion::{ FilenameCompleter, Completer, Pair }; -use rustyline::highlight::{ Highlighter, MatchingBracketHighlighter }; +use rustyline::highlight::Highlighter; use clap::{Arg, App}; use lazy_static::lazy_static; - struct RLHelper { completer: FilenameCompleter, highlighter: LineHighlighter, @@ -131,7 +131,15 @@ fn main() { hinter: AnswerHinter {} }; rl.set_helper(Some(h)); - if rl.load_history("history.txt").is_err() { + let mut history_path = PathBuf::new(); + match dirs::home_dir() { + Some(p) => { + history_path = p; + history_path.push("history.txt"); + }, + None => history_path.set_file_name("history.txt"), + }; + if rl.load_history(history_path.as_path()).is_err() { println!("No previous history.") }; @@ -151,7 +159,6 @@ fn main() { break }, Err(ReadlineError::Eof) => { - println!("CTRL-D"); break }, Err(err) => { @@ -160,7 +167,7 @@ fn main() { } } } - rl.save_history("history.txt").unwrap(); + rl.save_history(history_path.as_path()).unwrap(); } } -- cgit v1.2.3