Skip to content

Commit 30827d6

Browse files
committed
Make traverser operation less verbose
1 parent 1b28a31 commit 30827d6

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

src/traverse/traverser.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,9 @@ fn process_file(file_location: &FileLocation) -> Result<PageIndex, OperationResu
109109

110110
fn process_md_file(file_location: &FileLocation) -> Result<PageIndex, OperationResult> {
111111
let contents = fs::read_to_string(file_location.absolute_path.to_string())?;
112+
let first_line = contents.lines().find(|&l| !l.trim().is_empty());
112113

113-
// Gets the first non-empty line of the file
114-
let mut first_line = "";
115-
let mut lines = contents.lines();
116-
117-
while let Some(line) = lines.next() {
118-
if !line.trim().is_empty() {
119-
first_line = line;
120-
break;
121-
}
122-
}
123-
124-
match first_line.chars().next() {
114+
match first_line.unwrap_or_default().chars().next() {
125115
Some('+') => process_md_toml_front_matter(&contents, &file_location),
126116
Some('-') => process_md_yaml_front_matter(&contents, &file_location),
127117
// TODO: JSON frontmatter '{' => process_json_frontmatter()

0 commit comments

Comments
 (0)