1
- use clap :: { App , Arg , SubCommand , crate_version } ;
2
- use syntect :: easy :: HighlightFile ;
3
- use syntect :: parsing :: SyntaxSet ;
4
- use syntect :: highlighting :: { ThemeSet , Style } ;
5
- use syntect :: util :: { as_24_bit_terminal_escaped } ;
1
+ use crate :: run :: run ;
2
+ use crate :: verify :: verify ;
3
+ use clap :: { crate_version , App , Arg , SubCommand } ;
4
+ use notify :: DebouncedEvent ;
5
+ use notify :: { RecommendedWatcher , RecursiveMode , Watcher } ;
6
6
use std:: io:: BufRead ;
7
7
use std:: sync:: mpsc:: channel;
8
8
use std:: time:: Duration ;
9
- use notify :: DebouncedEvent ;
10
- use notify :: { RecommendedWatcher , Watcher , RecursiveMode } ;
11
- use crate :: verify :: verify ;
12
- use crate :: run :: run ;
9
+ use syntect :: easy :: HighlightFile ;
10
+ use syntect :: highlighting :: { Style , ThemeSet } ;
11
+ use syntect :: parsing :: SyntaxSet ;
12
+ use syntect :: util :: as_24_bit_terminal_escaped ;
13
13
14
14
mod run;
15
- mod verify;
16
15
mod util;
16
+ mod verify;
17
17
18
18
fn main ( ) {
19
19
let matches = App :: new ( "rustlings" )
@@ -26,11 +26,12 @@ fn main() {
26
26
SubCommand :: with_name ( "run" )
27
27
. alias ( "r" )
28
28
. arg ( Arg :: with_name ( "file" ) . required ( true ) . index ( 1 ) ) ,
29
- ) . get_matches ( ) ;
29
+ )
30
+ . get_matches ( ) ;
30
31
31
32
let ss = SyntaxSet :: load_defaults_newlines ( ) ;
32
33
let ts = ThemeSet :: load_defaults ( ) ;
33
-
34
+
34
35
println ! ( r#" _ _ _ "# ) ;
35
36
println ! ( r#" _ __ _ _ ___| |_| (_)_ __ __ _ ___ "# ) ;
36
37
println ! ( r#" | '__| | | / __| __| | | '_ \ / _` / __| "# ) ;
@@ -55,7 +56,8 @@ fn main() {
55
56
}
56
57
57
58
if let None = matches. subcommand_name ( ) {
58
- let mut highlighter = HighlightFile :: new ( "default_out.md" , & ss, & ts. themes [ "base16-eighties.dark" ] ) . unwrap ( ) ;
59
+ let mut highlighter =
60
+ HighlightFile :: new ( "default_out.md" , & ss, & ts. themes [ "base16-eighties.dark" ] ) . unwrap ( ) ;
59
61
for maybe_line in highlighter. reader . lines ( ) {
60
62
let line = maybe_line. unwrap ( ) ;
61
63
let regions: Vec < ( Style , & str ) > = highlighter. highlight_lines . highlight ( & line, & ss) ;
@@ -76,14 +78,11 @@ fn watch() -> notify::Result<()> {
76
78
77
79
loop {
78
80
match rx. recv ( ) {
79
- Ok ( event) => {
80
- match event {
81
- DebouncedEvent :: Chmod ( _)
82
- | DebouncedEvent :: Write ( _) => {
83
- let _ignored = verify ( ) ;
84
- }
85
- _ => { }
81
+ Ok ( event) => match event {
82
+ DebouncedEvent :: Chmod ( _) | DebouncedEvent :: Write ( _) => {
83
+ let _ignored = verify ( ) ;
86
84
}
85
+ _ => { }
87
86
} ,
88
87
Err ( e) => println ! ( "watch error: {:?}" , e) ,
89
88
}
0 commit comments