diff options
author | NerdyPepper <[email protected]> | 2019-06-23 12:46:56 +0100 |
---|---|---|
committer | NerdyPepper <[email protected]> | 2019-06-23 12:46:56 +0100 |
commit | d2d80030c1eaae9f08fb6a51c4159eed009086b6 (patch) | |
tree | 8003c015e6f2c6a8fdb42a5299e7aa2714e020b4 /src | |
parent | f869c6a1977146b71069fc137bcd4d5644ce60c6 (diff) |
remove unused imports, closes #16 and #17
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 19 |
1 files changed, 13 insertions, 6 deletions
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 @@ | |||
6 | 6 | ||
7 | // std | 7 | // std |
8 | use std::f64; | 8 | use std::f64; |
9 | use std::borrow::Cow::{self, Borrowed, Owned}; | 9 | use std::borrow::Cow::{self,Owned}; |
10 | use std::path::PathBuf; | ||
10 | 11 | ||
11 | // modules | 12 | // modules |
12 | mod lex; | 13 | mod lex; |
@@ -24,12 +25,11 @@ use rustyline::{ Editor, Context, Helper }; | |||
24 | use rustyline::config::{ Builder, ColorMode, EditMode, CompletionType }; | 25 | use rustyline::config::{ Builder, ColorMode, EditMode, CompletionType }; |
25 | use rustyline::hint::Hinter; | 26 | use rustyline::hint::Hinter; |
26 | use rustyline::completion::{ FilenameCompleter, Completer, Pair }; | 27 | use rustyline::completion::{ FilenameCompleter, Completer, Pair }; |
27 | use rustyline::highlight::{ Highlighter, MatchingBracketHighlighter }; | 28 | use rustyline::highlight::Highlighter; |
28 | 29 | ||
29 | use clap::{Arg, App}; | 30 | use clap::{Arg, App}; |
30 | use lazy_static::lazy_static; | 31 | use lazy_static::lazy_static; |
31 | 32 | ||
32 | |||
33 | struct RLHelper { | 33 | struct RLHelper { |
34 | completer: FilenameCompleter, | 34 | completer: FilenameCompleter, |
35 | highlighter: LineHighlighter, | 35 | highlighter: LineHighlighter, |
@@ -131,7 +131,15 @@ fn main() { | |||
131 | hinter: AnswerHinter {} | 131 | hinter: AnswerHinter {} |
132 | }; | 132 | }; |
133 | rl.set_helper(Some(h)); | 133 | rl.set_helper(Some(h)); |
134 | if rl.load_history("history.txt").is_err() { | 134 | let mut history_path = PathBuf::new(); |
135 | match dirs::home_dir() { | ||
136 | Some(p) => { | ||
137 | history_path = p; | ||
138 | history_path.push("history.txt"); | ||
139 | }, | ||
140 | None => history_path.set_file_name("history.txt"), | ||
141 | }; | ||
142 | if rl.load_history(history_path.as_path()).is_err() { | ||
135 | println!("No previous history.") | 143 | println!("No previous history.") |
136 | }; | 144 | }; |
137 | 145 | ||
@@ -151,7 +159,6 @@ fn main() { | |||
151 | break | 159 | break |
152 | }, | 160 | }, |
153 | Err(ReadlineError::Eof) => { | 161 | Err(ReadlineError::Eof) => { |
154 | println!("CTRL-D"); | ||
155 | break | 162 | break |
156 | }, | 163 | }, |
157 | Err(err) => { | 164 | Err(err) => { |
@@ -160,7 +167,7 @@ fn main() { | |||
160 | } | 167 | } |
161 | } | 168 | } |
162 | } | 169 | } |
163 | rl.save_history("history.txt").unwrap(); | 170 | rl.save_history(history_path.as_path()).unwrap(); |
164 | } | 171 | } |
165 | } | 172 | } |
166 | 173 | ||