Skip to content

Commit

Permalink
Make it easier to disable tts
Browse files Browse the repository at this point in the history
This is a small step in mitigating #1125
  • Loading branch information
emilk committed Jul 25, 2022
1 parent 0913c77 commit c02fbfe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions eframe/src/web/screen_reader.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
pub struct ScreenReader {
#[cfg(feature = "screen_reader")]
#[cfg(feature = "tts")]
tts: Option<tts::Tts>,
}

#[cfg(not(feature = "screen_reader"))]
#[cfg(not(feature = "tts"))]
#[allow(clippy::derivable_impls)] // False positive
impl Default for ScreenReader {
fn default() -> Self {
Self {}
}
}

#[cfg(feature = "screen_reader")]
#[cfg(feature = "tts")]
impl Default for ScreenReader {
fn default() -> Self {
let tts = match tts::Tts::default() {
Expand All @@ -29,11 +29,11 @@ impl Default for ScreenReader {
}

impl ScreenReader {
#[cfg(not(feature = "screen_reader"))]
#[cfg(not(feature = "tts"))]
#[allow(clippy::unused_self)]
pub fn speak(&mut self, _text: &str) {}

#[cfg(feature = "screen_reader")]
#[cfg(feature = "tts")]
pub fn speak(&mut self, text: &str) {
if text.is_empty() {
return;
Expand Down
10 changes: 5 additions & 5 deletions egui-winit/src/screen_reader.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
pub struct ScreenReader {
#[cfg(feature = "screen_reader")]
#[cfg(feature = "tts")]
tts: Option<tts::Tts>,
}

#[cfg(not(feature = "screen_reader"))]
#[cfg(not(feature = "tts"))]
#[allow(clippy::derivable_impls)] // False positive
impl Default for ScreenReader {
fn default() -> Self {
Self {}
}
}

#[cfg(feature = "screen_reader")]
#[cfg(feature = "tts")]
impl Default for ScreenReader {
fn default() -> Self {
let tts = match tts::Tts::default() {
Expand All @@ -29,11 +29,11 @@ impl Default for ScreenReader {
}

impl ScreenReader {
#[cfg(not(feature = "screen_reader"))]
#[cfg(not(feature = "tts"))]
#[allow(clippy::unused_self)]
pub fn speak(&mut self, _text: &str) {}

#[cfg(feature = "screen_reader")]
#[cfg(feature = "tts")]
pub fn speak(&mut self, text: &str) {
if text.is_empty() {
return;
Expand Down

0 comments on commit c02fbfe

Please sign in to comment.