generated from ewpratten/rust-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
41 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use eframe::egui::RichText; | ||
|
||
use crate::parse::ParsedLine; | ||
|
||
pub fn parse_line(line: &str) -> Option<ParsedLine> { | ||
// Read the line | ||
let mut reader = csv::ReaderBuilder::new() | ||
.has_headers(false) | ||
.comment(Some(b'#')) | ||
.trim(csv::Trim::All) | ||
.from_reader(line.as_bytes()); | ||
|
||
// Parse the line | ||
let mut cells = Vec::new(); | ||
for result in reader.records() { | ||
let record = result.unwrap(); | ||
for field in record.iter() { | ||
cells.push(RichText::new(field.to_string())); | ||
} | ||
} | ||
|
||
// If there are no cells, return None | ||
if cells.is_empty() || cells.iter().all(|c| c.text().is_empty()) { | ||
return None; | ||
} | ||
|
||
Some(ParsedLine::new(cells)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod spaces; | ||
pub mod spaces; | ||
pub mod csv; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters