From cc347dbf99fd79ee427fda1576717613ed3b7c2e Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Tue, 14 Apr 2020 00:32:24 +0100 Subject: [PATCH] allow empty dialogues (needs fixing) --- src/ending.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ending.rs b/src/ending.rs index 8a65e29..3038c94 100644 --- a/src/ending.rs +++ b/src/ending.rs @@ -8,9 +8,15 @@ pub struct Ending { impl From for Ending { fn from(string: String) -> Ending { let string = string.replace("END ", ""); + // todo this is wrong - we shouldn't be splitting on lines let id_dialogue: Vec<&str> = string.lines().collect(); let id = id_dialogue[0].to_string(); - let dialogue = id_dialogue[1].to_string(); + + let dialogue = if id_dialogue.len() > 1 { + id_dialogue[1] + } else { + "" + }.to_string(); Ending { id, dialogue } }