aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoris2022-11-02 14:47:20 +0100
committerJoris2022-11-02 14:47:20 +0100
commit2123e99f29a2ea7ccb73a072ecd7276f1eab9655 (patch)
treecbb55b9d17b2afc8257065e4528c186a9c8701ec /src
parente807957ce48368905f059c7b0c8e8116d98e37e1 (diff)
Allow comments at end of lines
Diffstat (limited to 'src')
-rw-r--r--src/deck.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/deck.rs b/src/deck.rs
index a414a02..70dfda1 100644
--- a/src/deck.rs
+++ b/src/deck.rs
@@ -39,7 +39,9 @@ pub fn read(deck: &str) -> Result<Vec<Entry>> {
message: "an entry should starts with “-”.".to_string(),
}));
} else {
- let translation = line[1..].trim().split(':').collect::<Vec<&str>>();
+ let without_minus = line.split('-').collect::<Vec<&str>>()[1].trim();
+ let without_comment = without_minus.split('#').collect::<Vec<&str>>()[0].trim();
+ let translation = without_comment.split(':').collect::<Vec<&str>>();
if translation.len() != 2 {
return Err(Error::from(ParseError {
line: index + 1,