Eliminate Option in return.

This commit is contained in:
Nolan Darilek 2020-09-30 16:03:04 -05:00
parent ff247a3f19
commit 69b5c39f66

View File

@ -174,7 +174,7 @@ impl TTS {
} }
#[export] #[export]
fn speak(&mut self, _owner: &Node, message: GodotString, interrupt: bool) -> Option<Variant> { fn speak(&mut self, _owner: &Node, message: GodotString, interrupt: bool) -> Variant {
let message = message.to_string(); let message = message.to_string();
if let Ok(id) = self.0.speak(message, interrupt) { if let Ok(id) = self.0.speak(message, interrupt) {
let utterance: Instance<Utterance, Unique> = Instance::new(); let utterance: Instance<Utterance, Unique> = Instance::new();
@ -183,9 +183,10 @@ impl TTS {
.map_mut(|u, _| u.0 = id) .map_mut(|u, _| u.0 = id)
.expect("Failed to set utterance ID"); .expect("Failed to set utterance ID");
} }
Some(utterance.owned_to_variant()) let utterance = utterance.owned_to_variant();
utterance
} else { } else {
None Variant::default()
} }
} }