From 2123e99f29a2ea7ccb73a072ecd7276f1eab9655 Mon Sep 17 00:00:00 2001 From: Joris Date: Wed, 2 Nov 2022 14:47:20 +0100 Subject: Allow comments at end of lines --- src/deck.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') 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> { message: "an entry should starts with “-”.".to_string(), })); } else { - let translation = line[1..].trim().split(':').collect::>(); + let without_minus = line.split('-').collect::>()[1].trim(); + let without_comment = without_minus.split('#').collect::>()[0].trim(); + let translation = without_comment.split(':').collect::>(); if translation.len() != 2 { return Err(Error::from(ParseError { line: index + 1, -- cgit v1.2.3