From ff247a3f191a347b067da7b20be35993d005074d Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Wed, 30 Sep 2020 15:25:59 -0500 Subject: [PATCH] Only set an utterance ID on the returned variant if we have one. --- src/lib.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 0a79814..a6d92a7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -178,9 +178,11 @@ impl TTS { let message = message.to_string(); if let Ok(id) = self.0.speak(message, interrupt) { let utterance: Instance = Instance::new(); - utterance - .map_mut(|u, _| u.0 = id) - .expect("Failed to set utterance ID"); + if id.is_some() { + utterance + .map_mut(|u, _| u.0 = id) + .expect("Failed to set utterance ID"); + } Some(utterance.owned_to_variant()) } else { None