Skip to content

Commit f6c294d

Browse files
committed
Removed unused imports
1 parent 4d9987f commit f6c294d

File tree

9 files changed

+53
-61
lines changed

9 files changed

+53
-61
lines changed

src/clojure_std/thread.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@ use crate::error_message;
22
use crate::ifn::IFn;
33
use crate::type_tag::TypeTag;
44
use crate::value::{ToValue, Value};
5-
use nom::lib::std::convert::TryFrom;
6-
use std::error::Error;
7-
use std::io::Read;
85
use std::rc::Rc;
96

10-
use std::thread;
117
use std::time;
128

139
/// provides a sleep function to sleep for given amount of ms

src/clojure_std/time.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
use crate::error_message;
22
use crate::ifn::IFn;
3-
use crate::type_tag::TypeTag;
43
use crate::value::{ToValue, Value};
5-
use nom::lib::std::convert::TryFrom;
6-
use std::error::Error;
7-
use std::io::Read;
84
use std::rc::Rc;
95

10-
use std::thread;
116
use std::time::{SystemTime, UNIX_EPOCH};
127

138
/// provides a function to return current time in nanoseconds

src/environment.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
use crate::clojure_std;
12
use crate::namespace::{Namespace, Namespaces};
2-
use crate::repl;
33
use crate::repl::Repl;
44
use crate::rust_core;
5-
use crate::clojure_std;
65
use crate::symbol::Symbol;
76
use crate::value::{ToValue, Value};
87

@@ -118,12 +117,15 @@ impl Environment {
118117
environment.insert(Symbol::intern("eval"), eval_fn.to_rc_value());
119118

120119
// Thread namespace TODO / instead of _
121-
environment.insert(Symbol::intern("Thread_sleep"), thread_sleep_fn.to_rc_value());
120+
environment.insert(
121+
Symbol::intern("Thread_sleep"),
122+
thread_sleep_fn.to_rc_value(),
123+
);
122124

123125
environment.insert(Symbol::intern("System_nanotime"), nanotime_fn.to_rc_value());
124126

125127
// core.clj wraps calls to the rust implementations
126-
// @TODO add this to clojure.rs.core namespace as clojure.rs.core/slurp
128+
// @TODO add this to clojure.rs.core namespace as clojure.rs.core/slurp
127129
environment.insert(Symbol::intern("rust-slurp"), slurp_fn.to_rc_value());
128130

129131
environment.insert(Symbol::intern("+"), add_fn.to_rc_value());
@@ -141,7 +143,7 @@ impl Environment {
141143
lexical_eval_fn.to_rc_value(),
142144
);
143145
environment.insert(Symbol::intern("nth"), nth_fn.to_rc_value());
144-
environment.insert(Symbol::intern("assoc"), assoc_fn.to_rc_value());
146+
environment.insert(Symbol::intern("assoc"), assoc_fn.to_rc_value());
145147
environment.insert(Symbol::intern("concat"), concat_fn.to_rc_value());
146148
environment.insert(
147149
Symbol::intern("print-string"),

src/error_message.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use crate::type_tag::TypeTag;
22
use crate::value::Value;
3-
use nom::error::ErrorKind;
4-
use nom::Err;
53
use std::error::Error;
64

75
pub fn type_mismatch(expected: TypeTag, got: &Value) -> Value {

src/reader.rs

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,19 @@
1010
1111
use nom::{
1212
branch::alt, bytes::complete::tag, map, sequence::preceded, take_until, terminated,
13-
Err::Incomplete, IResult, Needed,
13+
Err::Incomplete, IResult,
1414
};
1515

16+
use crate::keyword::Keyword;
1617
use crate::maps::MapEntry;
1718
use crate::persistent_list::ToPersistentList;
1819
use crate::persistent_list_map::ToPersistentListMap;
1920
use crate::persistent_vector::ToPersistentVector;
2021
use crate::symbol::Symbol;
21-
use crate::keyword::Keyword;
2222
use crate::value::{ToValue, Value};
2323
use std::rc::Rc;
2424

2525
use std::io::BufRead;
26-
use nom::Err::Error;
27-
use nom::error::ErrorKind;
2826
//
2927
// Note; the difference between ours 'parsers'
3028
// identifier_parser
@@ -78,7 +76,7 @@ fn cons_str(head: char, tail: &str) -> String {
7876
////////////////////////////////////////////////////////////////////////////////////////////////////
7977

8078
////////////////////////////////////////////////////////////////////////////////////////////////////
81-
//
79+
//
8280
// Predicates
8381
//
8482
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -150,12 +148,12 @@ fn is_clojure_whitespace(c: char) -> bool {
150148
c.is_whitespace() || c == ','
151149
}
152150
////////////////////////////////////////////////////////////////////////////////////////////////////
153-
// End predicates
151+
// End predicates
154152
////////////////////////////////////////////////////////////////////////////////////////////////////
155153

156154
///////////////////////////////////////////////////////////////////////////////////////////////////////
157-
//
158-
// Parsers
155+
//
156+
// Parsers
159157
//
160158
//////////////////////////////////////////////////////////////////////////////////////////////////////
161159

@@ -290,32 +288,31 @@ pub fn try_read_i32(input: &str) -> IResult<&str, Value> {
290288
/// false => Value::Boolean(false)
291289
pub fn try_read_bool(input: &str) -> IResult<&str, Value> {
292290
named!(bool_parser<&str,&str>, alt!( tag!("true") | tag!("false")));
293-
let (rest_input,bool) = bool_parser(input)?;
291+
let (rest_input, bool) = bool_parser(input)?;
294292
Ok((rest_input, Value::Boolean(bool.parse().unwrap())))
295293
}
296294

297-
298295
/// Tries to parse &str into Value::double
299296
///
300297
pub fn try_read_f64(input: &str) -> IResult<&str, Value> {
301298
to_value_parser(double_parser)(input)
302299
}
303300

304301
// Perhaps generalize this into reader macros
305-
/// Tries to parse &str into Value::Keyword
302+
/// Tries to parse &str into Value::Keyword
306303
/// Example Successes:
307304
/// :a => Value::Keyword(Keyword { sym: Symbol { name: "a" })
308-
/// :cat-dog => Value::Keyword(Keyword { sym: Symbol { name: "cat-dog" })
305+
/// :cat-dog => Value::Keyword(Keyword { sym: Symbol { name: "cat-dog" })
309306
/// Example Failures:
310-
/// :12 :'a
307+
/// :12 :'a
311308
pub fn try_read_keyword(input: &str) -> IResult<&str, Value> {
312309
named!(keyword_colon<&str, &str>, preceded!(consume_clojure_whitespaces_parser, tag!(":")));
313310

314311
let (rest_input, _) = keyword_colon(input)?;
315-
let (rest_input,symbol) = symbol_parser(rest_input)?;
312+
let (rest_input, symbol) = symbol_parser(rest_input)?;
316313

317314
let keyword_value = Keyword { sym: symbol }.to_value();
318-
Ok((rest_input,keyword_value))
315+
Ok((rest_input, keyword_value))
319316
}
320317

321318
/// Tries to parse &str into Value::Symbol
@@ -421,28 +418,34 @@ pub fn try_read_list(input: &str) -> IResult<&str, Value> {
421418
pub fn try_read_quoted(input: &str) -> IResult<&str, Value> {
422419
named!(quote<&str, &str>, preceded!(consume_clojure_whitespaces_parser, tag!("'")));
423420

424-
let (form,_) = quote(input)?;
421+
let (form, _) = quote(input)?;
425422

426-
let (rest_input,quoted_form_value) = try_read(form)?;
423+
let (rest_input, quoted_form_value) = try_read(form)?;
427424

428-
// (quote value)
429-
Ok((rest_input,
430-
vec![Symbol::intern("quote").to_rc_value(),
431-
quoted_form_value .to_rc_value()].into_list().to_value()))
425+
// (quote value)
426+
Ok((
427+
rest_input,
428+
vec![
429+
Symbol::intern("quote").to_rc_value(),
430+
quoted_form_value.to_rc_value(),
431+
]
432+
.into_list()
433+
.to_value(),
434+
))
432435
}
433436

434437
pub fn try_read(input: &str) -> IResult<&str, Value> {
435438
preceded(
436439
consume_clojure_whitespaces_parser,
437440
alt((
438-
try_read_quoted,
441+
try_read_quoted,
439442
try_read_map,
440443
try_read_string,
441444
try_read_f64,
442445
try_read_i32,
443446
try_read_bool,
444447
try_read_symbol,
445-
try_read_keyword,
448+
try_read_keyword,
446449
try_read_list,
447450
try_read_vector,
448451
)),
@@ -454,7 +457,7 @@ pub fn try_read(input: &str) -> IResult<&str, Value> {
454457

455458
////////////////////////////////////////////////////////////////////////////////////////////////////
456459
//
457-
// Readers
460+
// Readers
458461
//
459462
///////////////////////////////////////////////////////////////////////////////////////////////////
460463

@@ -471,7 +474,9 @@ pub fn read<R: BufRead>(reader: &mut R) -> Value {
471474
match maybe_line {
472475
Some(Err(e)) => return Value::Condition(format!("Reader error: {}", e)),
473476
Some(Ok(line)) => input_buffer.push_str(&line),
474-
None => return Value::Condition(String::from("Tried to read empty stream; unexpected EOF")),
477+
None => {
478+
return Value::Condition(String::from("Tried to read empty stream; unexpected EOF"))
479+
}
475480
}
476481

477482
let line_read = try_read(&input_buffer);
@@ -594,7 +599,7 @@ mod tests {
594599
}
595600

596601
mod integer_parser_tests {
597-
use crate::reader::{integer_parser};
602+
use crate::reader::integer_parser;
598603

599604
#[test]
600605
fn integer_parser_parses_integer_one() {
@@ -623,8 +628,8 @@ mod tests {
623628
}
624629

625630
mod try_read_bool_tests {
626-
use crate::value::Value;
627631
use crate::reader::try_read_bool;
632+
use crate::value::Value;
628633

629634
#[test]
630635
fn try_read_boolean_true_test() {
@@ -633,7 +638,10 @@ mod tests {
633638

634639
#[test]
635640
fn try_read_boolean_false_test() {
636-
assert_eq!(Value::Boolean(false), try_read_bool("false ").ok().unwrap().1);
641+
assert_eq!(
642+
Value::Boolean(false),
643+
try_read_bool("false ").ok().unwrap().1
644+
);
637645
}
638646
}
639647

@@ -654,15 +662,13 @@ mod tests {
654662
}
655663

656664
mod try_read_tests {
657-
use crate::maps::MapEntry;
658665
use crate::persistent_list;
659666
use crate::persistent_list_map;
660667
use crate::persistent_vector;
661668
use crate::reader::try_read;
662669
use crate::symbol::Symbol;
663670
use crate::value::Value;
664671
use crate::value::Value::{PersistentList, PersistentListMap, PersistentVector};
665-
use std::rc::Rc;
666672

667673
#[test]
668674
fn try_read_empty_map_test() {
@@ -743,18 +749,12 @@ mod tests {
743749

744750
#[test]
745751
fn try_read_bool_true_test() {
746-
assert_eq!(
747-
Value::Boolean(true),
748-
try_read("true ").ok().unwrap().1
749-
)
752+
assert_eq!(Value::Boolean(true), try_read("true ").ok().unwrap().1)
750753
}
751754

752755
#[test]
753756
fn try_read_bool_false_test() {
754-
assert_eq!(
755-
Value::Boolean(false),
756-
try_read("false ").ok().unwrap().1
757-
)
757+
assert_eq!(Value::Boolean(false), try_read("false ").ok().unwrap().1)
758758
}
759759
}
760760

@@ -776,7 +776,10 @@ mod tests {
776776
#[test]
777777
fn consume_whitespaces_from_input_no_whitespace() {
778778
let s = "1, 2, 3";
779-
assert_eq!(Some(("1, 2, 3", ())), consume_clojure_whitespaces_parser(&s).ok());
779+
assert_eq!(
780+
Some(("1, 2, 3", ())),
781+
consume_clojure_whitespaces_parser(&s).ok()
782+
);
780783
}
781784
}
782785

src/repl.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::fs::File;
22
use std::io;
33
use std::io::BufRead;
44
use std::io::BufReader;
5-
use std::io::Read;
65
use std::io::Write;
76

87
use crate::environment::Environment;

src/rust_core/print_string.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::ifn::IFn;
2-
use crate::value::{Value, ToValue, Evaluable};
2+
use crate::value::{ToValue, Value};
33
use std::rc::Rc;
44

55
use crate::error_message;
@@ -16,9 +16,9 @@ impl ToValue for PrintStringFn {
1616
impl IFn for PrintStringFn {
1717
fn invoke(&self, args: Vec<Rc<Value>>) -> Value {
1818
if args.len() != 1 {
19-
return error_message::wrong_arg_count(1, args.len())
19+
return error_message::wrong_arg_count(1, args.len());
2020
}
2121
println!("{}", args.get(0).unwrap().to_string());
2222
Value::Nil
2323
}
24-
}
24+
}

src/rust_core/slurp.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use reqwest;
1010
use url::Url;
1111

1212
use crate::error_message;
13-
use std::error::Error;
1413

1514
/// (slurp f & opts)
1615
///

src/rust_core/string_print.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::ifn::IFn;
2-
use crate::value::{Value, ToValue, Evaluable};
2+
use crate::value::{ToValue, Value};
33
use std::rc::Rc;
44

55
// Todo: dead code? no usage found

0 commit comments

Comments
 (0)