From 9bd767629a123fc6a4303eddc4082f3b425f2e9f Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Thu, 31 Mar 2022 13:18:57 -0500 Subject: [PATCH] Remove unspecified gender in favor of `Option`. --- src/backends/av_foundation.rs | 6 +++--- src/lib.rs | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/backends/av_foundation.rs b/src/backends/av_foundation.rs index d1b5dca..4f87395 100644 --- a/src/backends/av_foundation.rs +++ b/src/backends/av_foundation.rs @@ -298,9 +298,9 @@ impl Backend for AvFoundation { let name: CFString = unsafe { msg_send![*v as *const Object, name] }; let gender: i64 = unsafe { msg_send![*v as *const Object, gender] }; let gender = match gender { - 0 => Gender::Male, - 1 => Gender::Female, - _ => Gender::Unspecified, + 0 => Some(Gender::Male), + 1 => Some(Gender::Female), + _ => None, }; let language: CFString = unsafe { msg_send![*v as *const Object, language] }; let language = language.to_string(); diff --git a/src/lib.rs b/src/lib.rs index db970f1..4b56bd1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -704,7 +704,6 @@ impl Drop for Tts { #[derive(Clone, Copy, Debug)] pub enum Gender { - Unspecified, Male, Female, } @@ -713,7 +712,7 @@ pub enum Gender { pub struct Voice { pub(crate) id: String, pub(crate) name: String, - pub(crate) gender: Gender, + pub(crate) gender: Option, pub(crate) language: LanguageIdentifier, } @@ -726,7 +725,7 @@ impl Voice { self.name.clone() } - pub fn gender(&self) -> Gender { + pub fn gender(&self) -> Option { self.gender }