1
Fork 0
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:
Joshua Goins 2024-04-15 18:50:01 -04:00
parent f80b290c4e
commit 840682e1d0

View file

@ -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 Some((name, value)) = line.split_once(',') {
if let Ok(parsed_value) = value.parse() {
if let Ok(line) = line {
if let Some((name, value)) = line.split_once(',') {
let parsed_value: i32 = value.parse().unwrap();
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));
} }
} }
} }