aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoris2022-11-02 14:47:20 +0100
committerJoris2022-11-02 14:47:20 +0100
commit2123e99f29a2ea7ccb73a072ecd7276f1eab9655 (patch)
treecbb55b9d17b2afc8257065e4528c186a9c8701ec
parente807957ce48368905f059c7b0c8e8116d98e37e1 (diff)
downloadflashcards-2123e99f29a2ea7ccb73a072ecd7276f1eab9655.tar.gz
flashcards-2123e99f29a2ea7ccb73a072ecd7276f1eab9655.tar.bz2
flashcards-2123e99f29a2ea7ccb73a072ecd7276f1eab9655.zip
Allow comments at end of lines
-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,