Make it easier to disable tts

This is a small step in mitigating https://github.com/emilk/egui/issues/1125
This commit is contained in:
Emil Ernerfeldt 2022-07-25 22:17:52 +02:00
parent 0913c77f3d
commit c02fbfe973
2 changed files with 10 additions and 10 deletions

View file

@ -1,9 +1,9 @@
pub struct ScreenReader { pub struct ScreenReader {
#[cfg(feature = "screen_reader")] #[cfg(feature = "tts")]
tts: Option<tts::Tts>, tts: Option<tts::Tts>,
} }
#[cfg(not(feature = "screen_reader"))] #[cfg(not(feature = "tts"))]
#[allow(clippy::derivable_impls)] // False positive #[allow(clippy::derivable_impls)] // False positive
impl Default for ScreenReader { impl Default for ScreenReader {
fn default() -> Self { fn default() -> Self {
@ -11,7 +11,7 @@ impl Default for ScreenReader {
} }
} }
#[cfg(feature = "screen_reader")] #[cfg(feature = "tts")]
impl Default for ScreenReader { impl Default for ScreenReader {
fn default() -> Self { fn default() -> Self {
let tts = match tts::Tts::default() { let tts = match tts::Tts::default() {
@ -29,11 +29,11 @@ impl Default for ScreenReader {
} }
impl ScreenReader { impl ScreenReader {
#[cfg(not(feature = "screen_reader"))] #[cfg(not(feature = "tts"))]
#[allow(clippy::unused_self)] #[allow(clippy::unused_self)]
pub fn speak(&mut self, _text: &str) {} pub fn speak(&mut self, _text: &str) {}
#[cfg(feature = "screen_reader")] #[cfg(feature = "tts")]
pub fn speak(&mut self, text: &str) { pub fn speak(&mut self, text: &str) {
if text.is_empty() { if text.is_empty() {
return; return;

View file

@ -1,9 +1,9 @@
pub struct ScreenReader { pub struct ScreenReader {
#[cfg(feature = "screen_reader")] #[cfg(feature = "tts")]
tts: Option<tts::Tts>, tts: Option<tts::Tts>,
} }
#[cfg(not(feature = "screen_reader"))] #[cfg(not(feature = "tts"))]
#[allow(clippy::derivable_impls)] // False positive #[allow(clippy::derivable_impls)] // False positive
impl Default for ScreenReader { impl Default for ScreenReader {
fn default() -> Self { fn default() -> Self {
@ -11,7 +11,7 @@ impl Default for ScreenReader {
} }
} }
#[cfg(feature = "screen_reader")] #[cfg(feature = "tts")]
impl Default for ScreenReader { impl Default for ScreenReader {
fn default() -> Self { fn default() -> Self {
let tts = match tts::Tts::default() { let tts = match tts::Tts::default() {
@ -29,11 +29,11 @@ impl Default for ScreenReader {
} }
impl ScreenReader { impl ScreenReader {
#[cfg(not(feature = "screen_reader"))] #[cfg(not(feature = "tts"))]
#[allow(clippy::unused_self)] #[allow(clippy::unused_self)]
pub fn speak(&mut self, _text: &str) {} pub fn speak(&mut self, _text: &str) {}
#[cfg(feature = "screen_reader")] #[cfg(feature = "tts")]
pub fn speak(&mut self, text: &str) { pub fn speak(&mut self, text: &str) {
if text.is_empty() { if text.is_empty() {
return; return;