Skip to content

Commit e854727

Browse files
committed
rustfmt woke up
1 parent b324bf8 commit e854727

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

src/file_parser/codefile.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl CodeFile {
4444
eprintln!("No code file found! Try creating a file named with proper extension",);
4545
std::process::exit(1);
4646
});
47-
let Ok(code) = std::fs::read_to_string(&code_file.path) else {
47+
let Ok(code) = std::fs::read_to_string(&code_file.path) else {
4848
eprintln!("Error reading the code file!");
4949
std::process::exit(1);
5050
};
@@ -65,14 +65,14 @@ impl CodeFile {
6565
let language = Language::from_str(extension)?;
6666

6767
Some((
68-
file_name,
69-
CodeFile {
70-
language,
71-
path: path.clone(),
72-
question_title: String::new(),
73-
code: String::new(),
74-
},
75-
))
68+
file_name,
69+
CodeFile {
70+
language,
71+
path: path.clone(),
72+
question_title: String::new(),
73+
code: String::new(),
74+
},
75+
))
7676
}
7777

7878
fn parse_code(code: &str, language: Language) -> Result<(String, String), &str> {
@@ -95,15 +95,17 @@ impl CodeFile {
9595
return Err("No leetcode problem found in the code file. Please add the problem link in the code file using comments.");
9696
}
9797
let code = code[start..end].trim();
98-
let code = code.trim_end_matches(language.inline_comment_start()).trim_end();
98+
let code = code
99+
.trim_end_matches(language.inline_comment_start())
100+
.trim_end();
99101
parsed_code = code.to_string();
100102

101103
Ok((question_title, parsed_code))
102104
}
103105

104106
pub fn from_file(path: &str) -> Self {
105107
let path = PathBuf::from(&path);
106-
let Some(file) = Self::is_valid_file(&path) else {
108+
let Some(file) = Self::is_valid_file(&path) else {
107109
eprintln!("Invalid file!");
108110
std::process::exit(1);
109111
};

src/utils.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
use crate::file_parser::codefile::CodeFile;
2+
use crate::handlers::leetcode::{Authorized, LeetCode};
23
use crate::handlers::utils::{ExecutionResult, SubmissionResult};
34
use colored::Colorize;
4-
use crate::handlers::leetcode::{Authorized, LeetCode};
55
use std::process::ExitCode;
66

7-
87
pub(crate) fn execute_testcases(
98
filename: Option<String>,
109
testcases: Option<String>,
1110
lc: &LeetCode<Authorized>,
12-
) -> (bool, CodeFile) {
11+
) -> (bool, CodeFile) {
1312
let is_correct;
1413
let code_file: CodeFile;
1514
if let Some(filename) = filename {
@@ -20,7 +19,7 @@ pub(crate) fn execute_testcases(
2019
if let Some(testcases) = testcases {
2120
let Ok(data_input) = std::fs::read_to_string(&testcases) else{
2221
eprintln!("Error opening testcases file!");
23-
return (false, code_file);
22+
return (false, code_file);
2423
};
2524
match lc.execute(&code_file, data_input) {
2625
Ok(result) => {
@@ -69,7 +68,7 @@ pub(crate) fn execute_testcases(
6968
println!(
7069
"{}",
7170
"Testcases can be found in testcase.txt".yellow().italic()
72-
);
71+
);
7372
}
7473
result.is_correct()
7574
}

0 commit comments

Comments
 (0)