Skip to content

Commit 43579d8

Browse files
committed
rustfmt
1 parent 084c1fe commit 43579d8

File tree

2 files changed

+76
-33
lines changed

2 files changed

+76
-33
lines changed

src/reader.rs

Lines changed: 69 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,10 @@ mod tests {
405405

406406
#[test]
407407
fn identifier_parser_parses_valid_identifier() {
408-
assert_eq!(Some((" this", String::from("input->output?"))), identifier_parser("input->output? this").ok());
408+
assert_eq!(
409+
Some((" this", String::from("input->output?"))),
410+
identifier_parser("input->output? this").ok()
411+
);
409412
}
410413

411414
#[test]
@@ -425,7 +428,15 @@ mod tests {
425428

426429
#[test]
427430
fn identifier_parser_parses_valid_identifier() {
428-
assert_eq!(Some((" this", Symbol { name: String::from("input->output?")})), symbol_parser("input->output? this").ok());
431+
assert_eq!(
432+
Some((
433+
" this",
434+
Symbol {
435+
name: String::from("input->output?")
436+
}
437+
)),
438+
symbol_parser("input->output? this").ok()
439+
);
429440
}
430441

431442
#[test]
@@ -440,7 +451,7 @@ mod tests {
440451
}
441452

442453
mod integer_parser_tests {
443-
use crate::reader::{integer_parser, debug_try_read};
454+
use crate::reader::{debug_try_read, integer_parser};
444455

445456
#[test]
446457
fn integer_parser_parses_integer_one() {
@@ -466,45 +477,54 @@ mod tests {
466477
let s = "-1-2 ";
467478
assert_eq!(Some(("-2 ", -1)), integer_parser(s).ok());
468479
}
469-
470480
}
471481

472482
mod try_read_symbol_tests {
473-
use crate::value::Value;
474-
use crate::symbol::Symbol;
475483
use crate::reader::try_read_symbol;
484+
use crate::symbol::Symbol;
485+
use crate::value::Value;
476486

477487
#[test]
478488
fn try_read_minus_as_valid_symbol_test() {
479-
assert_eq!(Value::Symbol(Symbol { name: String::from("-")}) , try_read_symbol("- ").unwrap().1);
489+
assert_eq!(
490+
Value::Symbol(Symbol {
491+
name: String::from("-")
492+
}),
493+
try_read_symbol("- ").unwrap().1
494+
);
480495
}
481496
}
482497

483498
mod try_read_tests {
484-
use crate::reader::try_read;
485-
use crate::value::{Value};
486-
use crate::symbol::Symbol;
487-
use crate::persistent_list_map;
499+
use crate::maps::MapEntry;
488500
use crate::persistent_list;
501+
use crate::persistent_list_map;
489502
use crate::persistent_vector;
490-
use crate::value::Value::{PersistentListMap, PersistentList, PersistentVector};
491-
use crate::maps::MapEntry;
503+
use crate::reader::try_read;
504+
use crate::symbol::Symbol;
505+
use crate::value::Value;
506+
use crate::value::Value::{PersistentList, PersistentListMap, PersistentVector};
492507
use std::rc::Rc;
493508

494509
#[test]
495510
fn try_read_empty_map_test() {
496-
assert_eq!(PersistentListMap(persistent_list_map::PersistentListMap::Empty), try_read("{} ").ok().unwrap().1);
511+
assert_eq!(
512+
PersistentListMap(persistent_list_map::PersistentListMap::Empty),
513+
try_read("{} ").ok().unwrap().1
514+
);
497515
}
498516

499517
#[test]
500518
fn try_read_string_test() {
501-
assert_eq!(Value::String(String::from("a string")), try_read("\"a string\" ").ok().unwrap().1);
519+
assert_eq!(
520+
Value::String(String::from("a string")),
521+
try_read("\"a string\" ").ok().unwrap().1
522+
);
502523
}
503524

504525
#[test]
505526
fn try_read_int_test() {
506527
assert_eq!(Value::I32(1), try_read("1 ").ok().unwrap().1);
507-
508528
}
509529

510530
#[test]
@@ -519,47 +539,69 @@ mod tests {
519539

520540
#[test]
521541
fn try_read_valid_symbol_test() {
522-
assert_eq!(Value::Symbol(Symbol { name: String::from("my-symbol")}) , try_read("my-symbol ").ok().unwrap().1);
542+
assert_eq!(
543+
Value::Symbol(Symbol {
544+
name: String::from("my-symbol")
545+
}),
546+
try_read("my-symbol ").ok().unwrap().1
547+
);
523548
}
524549

525550
#[test]
526551
fn try_read_minus_as_valid_symbol_test() {
527-
assert_eq!(Value::Symbol(Symbol { name: String::from("-")}) , try_read("- ").ok().unwrap().1);
552+
assert_eq!(
553+
Value::Symbol(Symbol {
554+
name: String::from("-")
555+
}),
556+
try_read("- ").ok().unwrap().1
557+
);
528558
}
529559

530560
#[test]
531561
fn try_read_minus_prefixed_as_valid_symbol_test() {
532-
assert_eq!(Value::Symbol(Symbol { name: String::from("-prefixed")}) , try_read("-prefixed ").ok().unwrap().1);
562+
assert_eq!(
563+
Value::Symbol(Symbol {
564+
name: String::from("-prefixed")
565+
}),
566+
try_read("-prefixed ").ok().unwrap().1
567+
);
533568
}
534569

535570
#[test]
536571
fn try_read_empty_list_test() {
537-
assert_eq!(PersistentList(persistent_list::PersistentList::Empty), try_read("() ").ok().unwrap().1);
572+
assert_eq!(
573+
PersistentList(persistent_list::PersistentList::Empty),
574+
try_read("() ").ok().unwrap().1
575+
);
538576
}
539577

540578
#[test]
541579
fn try_read_empty_vector_test() {
542-
assert_eq!(PersistentVector(persistent_vector::PersistentVector { vals: [].to_vec() }), try_read("[] ").ok().unwrap().1);
580+
assert_eq!(
581+
PersistentVector(persistent_vector::PersistentVector { vals: [].to_vec() }),
582+
try_read("[] ").ok().unwrap().1
583+
);
543584
}
544-
545-
546585
}
547586

548587
mod consume_clojure_whitespaces_tests {
549588
use crate::reader::consume_clojure_whitespaces;
550589
#[test]
551590
fn consume_whitespaces_from_input() {
552-
let s = ", ,, ,1, 2, 3, 4 5,,6 ";
553-
assert_eq!(Some(("1, 2, 3, 4 5,,6 ", ())), consume_clojure_whitespaces(&s).ok());
591+
let s = ", ,, ,1, 2, 3, 4 5,,6 ";
592+
assert_eq!(
593+
Some(("1, 2, 3, 4 5,,6 ", ())),
594+
consume_clojure_whitespaces(&s).ok()
595+
);
554596
}
555597
#[test]
556598
fn consume_whitespaces_from_empty_input() {
557-
let s = "";
599+
let s = "";
558600
assert_eq!(None, consume_clojure_whitespaces(&s).ok());
559601
}
560602
#[test]
561603
fn consume_whitespaces_from_input_no_whitespace() {
562-
let s = "1, 2, 3";
604+
let s = "1, 2, 3";
563605
assert_eq!(Some(("1, 2, 3", ())), consume_clojure_whitespaces(&s).ok());
564606
}
565607
}
@@ -581,5 +623,4 @@ mod tests {
581623
assert_eq!(false, is_clojure_whitespace('a'));
582624
}
583625
}
584-
585626
}

src/value.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ use crate::type_tag::TypeTag;
1212
extern crate rand;
1313
use rand::Rng;
1414

15+
use std::cmp::{Ord, Ordering};
1516
use std::fmt;
1617
use std::fmt::Debug;
1718
use std::hash::{Hash, Hasher};
1819
use std::rc::Rc;
19-
use std::cmp::{Ord, Ordering};
2020

2121
// @TODO Change IFn's name -- IFn is a function, not an IFn.
2222
// The body it executes just happens to be an the IFn.
@@ -691,10 +691,12 @@ impl Evaluable for Rc<Value> {
691691
//
692692
// Sounds less correct but also seems clearer; the current error message relies on
693693
// you pretty much already knowing when this error message is called
694-
try_apply_ifn.unwrap_or_else(|| Rc::new(Value::Condition(format!(
695-
"Execution Error: {} cannot be cast to clojure.lang.IFn",
696-
ifn.type_tag()
697-
))))
694+
try_apply_ifn.unwrap_or_else(|| {
695+
Rc::new(Value::Condition(format!(
696+
"Execution Error: {} cannot be cast to clojure.lang.IFn",
697+
ifn.type_tag()
698+
)))
699+
})
698700
}
699701
// () evals to ()
700702
PersistentList::Empty => Rc::new(Value::PersistentList(PersistentList::Empty)),

0 commit comments

Comments
 (0)