From 1507527175beca9486ae3b7536bf3872dd7b4555 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Mon, 24 Aug 2020 16:44:00 -0500 Subject: [PATCH] Add `Default` implementation for `Features` so backends need only specify features they actually support. --- src/backends/appkit.rs | 2 +- src/backends/tolk.rs | 5 +---- src/lib.rs | 12 ++++++++++++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/backends/appkit.rs b/src/backends/appkit.rs index 6bfbf06..dcc68d9 100644 --- a/src/backends/appkit.rs +++ b/src/backends/appkit.rs @@ -95,9 +95,9 @@ impl Backend for AppKit { Features { stop: true, rate: true, - pitch: false, volume: true, is_speaking: true, + ..Default::default(), } } diff --git a/src/backends/tolk.rs b/src/backends/tolk.rs index 176fdb7..b56a9b0 100644 --- a/src/backends/tolk.rs +++ b/src/backends/tolk.rs @@ -22,10 +22,7 @@ impl Backend for Tolk { fn supported_features(&self) -> Features { Features { stop: true, - rate: false, - pitch: false, - volume: false, - is_speaking: false, + ..Default::default(), } } diff --git a/src/lib.rs b/src/lib.rs index b64c86b..56b9f32 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -48,6 +48,18 @@ pub struct Features { pub is_speaking: bool, } +impl Default for Features { + fn default() -> Self { + Self { + stop: false, + rate: false, + pitch: false, + volume: false, + is_speaking: false, + } + } +} + #[derive(Debug, Error)] pub enum Error { #[error("IO error: {0}")]