Skip to content

Commit e03a98c

Browse files
author
liv
committed
rustfmt
1 parent a388bb3 commit e03a98c

File tree

3 files changed

+25
-28
lines changed

3 files changed

+25
-28
lines changed

src/main.rs

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
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};
66
use std::io::BufRead;
77
use std::sync::mpsc::channel;
88
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;
1313

1414
mod run;
15-
mod verify;
1615
mod util;
16+
mod verify;
1717

1818
fn main() {
1919
let matches = App::new("rustlings")
@@ -26,11 +26,12 @@ fn main() {
2626
SubCommand::with_name("run")
2727
.alias("r")
2828
.arg(Arg::with_name("file").required(true).index(1)),
29-
).get_matches();
29+
)
30+
.get_matches();
3031

3132
let ss = SyntaxSet::load_defaults_newlines();
3233
let ts = ThemeSet::load_defaults();
33-
34+
3435
println!(r#" _ _ _ "#);
3536
println!(r#" _ __ _ _ ___| |_| (_)_ __ __ _ ___ "#);
3637
println!(r#" | '__| | | / __| __| | | '_ \ / _` / __| "#);
@@ -55,7 +56,8 @@ fn main() {
5556
}
5657

5758
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();
5961
for maybe_line in highlighter.reader.lines() {
6062
let line = maybe_line.unwrap();
6163
let regions: Vec<(Style, &str)> = highlighter.highlight_lines.highlight(&line, &ss);
@@ -76,14 +78,11 @@ fn watch() -> notify::Result<()> {
7678

7779
loop {
7880
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();
8684
}
85+
_ => {}
8786
},
8887
Err(e) => println!("watch error: {:?}", e),
8988
}

src/run.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
use crate::util::clean;
12
use console::{style, Emoji};
23
use indicatif::ProgressBar;
34
use std::process::Command;
4-
use crate::util::clean;
55

66
pub fn run(matches: clap::ArgMatches) {
77
if let Some(filename) = matches.value_of("file") {
@@ -16,19 +16,17 @@ pub fn run(matches: clap::ArgMatches) {
1616
if compilecmd.status.success() {
1717
let runcmd = Command::new("./temp").output().expect("fail");
1818
bar.finish_and_clear();
19-
19+
2020
if runcmd.status.success() {
2121
println!("{}", String::from_utf8_lossy(&runcmd.stdout));
22-
let formatstr =
23-
format!("{} Successfully ran {}", Emoji("✅", "✓"), filename);
22+
let formatstr = format!("{} Successfully ran {}", Emoji("✅", "✓"), filename);
2423
println!("{}", style(formatstr).green());
2524
clean();
2625
} else {
2726
println!("{}", String::from_utf8_lossy(&runcmd.stdout));
2827
println!("{}", String::from_utf8_lossy(&runcmd.stderr));
29-
30-
let formatstr =
31-
format!("{} Ran {} with errors", Emoji("⚠️ ", "!"), filename);
28+
29+
let formatstr = format!("{} Ran {} with errors", Emoji("⚠️ ", "!"), filename);
3230
println!("{}", style(formatstr).red());
3331
clean();
3432
}

src/verify.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
use crate::util::clean;
12
use console::{style, Emoji};
23
use indicatif::ProgressBar;
34
use std::process::Command;
4-
use crate::util::clean;
55

66
pub fn verify() -> Result<(), ()> {
77
compile_only("exercises/ex1.rs")?;

0 commit comments

Comments
 (0)