mirror of
https://github.com/redstrate/Physis.git
synced 2025-04-30 07:57:45 +00:00
Simplify some EXL parsing code
This commit is contained in:
parent
f80b290c4e
commit
840682e1d0
1 changed files with 4 additions and 8 deletions
10
src/exl.rs
10
src/exl.rs
|
@ -24,18 +24,14 @@ impl EXL {
|
||||||
let cursor = Cursor::new(buffer);
|
let cursor = Cursor::new(buffer);
|
||||||
let reader = BufReader::new(cursor);
|
let reader = BufReader::new(cursor);
|
||||||
|
|
||||||
for line in reader.lines() {
|
for line in reader.lines().flatten() {
|
||||||
// now parse the line!
|
|
||||||
|
|
||||||
if let Ok(line) = line {
|
|
||||||
if let Some((name, value)) = line.split_once(',') {
|
if let Some((name, value)) = line.split_once(',') {
|
||||||
let parsed_value: i32 = value.parse().unwrap();
|
if let Ok(parsed_value) = value.parse() {
|
||||||
|
|
||||||
if name == "EXLT" {
|
if name == "EXLT" {
|
||||||
exl.version = parsed_value;
|
exl.version = parsed_value;
|
||||||
} else if !name.starts_with('#') {
|
} else if !name.starts_with('#') {
|
||||||
// Ignore rows with comments
|
// Ignore rows with comments
|
||||||
exl.entries.push((name.parse().unwrap(), parsed_value));
|
exl.entries.push((name.to_string(), parsed_value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue