From e82a10ba1620f2ecae8867d4188364963118aff4 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Thu, 3 Jan 2019 16:16:54 +0000 Subject: [PATCH] cargo fmt --- src/backends/speech_dispatcher.rs | 3 +-- src/backends/web.rs | 1 - src/lib.rs | 21 ++++++++++----------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/backends/speech_dispatcher.rs b/src/backends/speech_dispatcher.rs index 6b400e6..ed0b93b 100644 --- a/src/backends/speech_dispatcher.rs +++ b/src/backends/speech_dispatcher.rs @@ -1,5 +1,4 @@ #[cfg(target_os = "linux")] - use std::u8; use log::{info, trace}; @@ -18,7 +17,7 @@ impl SpeechDispatcher { } fn u8_to_i32(v: u8) -> i32 { - let ratio: f32 = v as f32/u8::MAX as f32; + let ratio: f32 = v as f32 / u8::MAX as f32; (ratio * 200. - 100.) as i32 } diff --git a/src/backends/web.rs b/src/backends/web.rs index 6167196..89f7f72 100644 --- a/src/backends/web.rs +++ b/src/backends/web.rs @@ -1,5 +1,4 @@ #[cfg(target_arch = "wasm32")] - use std::u8; use log::{info, trace}; diff --git a/src/lib.rs b/src/lib.rs index d1e9f42..bc873e4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -51,10 +51,9 @@ trait Backend { pub struct TTS(Box); impl TTS { - /** * Create a new `TTS` instance with the specified backend. - */ + */ pub fn new(backend: Backends) -> Result { match backend { #[cfg(target_os = "linux")] @@ -63,7 +62,7 @@ impl TTS { Backends::Web => { let tts = backends::Web::new()?; Ok(TTS(Box::new(tts))) - }, + } } } @@ -77,7 +76,7 @@ impl TTS { /** * Speaks the specified text, optionally interrupting current speech. - */ + */ pub fn speak>(&self, text: S, interrupt: bool) -> Result<&Self, Error> { self.0.speak(text.into().as_str(), interrupt)?; Ok(self) @@ -85,7 +84,7 @@ impl TTS { /** * Stops current speech. - */ + */ pub fn stop(&self) -> Result<&Self, Error> { self.0.stop()?; Ok(self) @@ -93,14 +92,14 @@ impl TTS { /** * Gets the current speech rate. - */ + */ pub fn get_rate(&self) -> Result { self.0.get_rate() } /** * Sets the desired speech rate. - */ + */ pub fn set_rate(&mut self, rate: u8) -> Result<&Self, Error> { self.0.set_rate(rate)?; Ok(self) @@ -108,14 +107,14 @@ impl TTS { /** * Gets the current speech pitch. - */ + */ pub fn get_pitch(&self) -> Result { self.0.get_pitch() } /** * Sets the desired speech pitch. - */ + */ pub fn set_pitch(&mut self, pitch: u8) -> Result<&Self, Error> { self.0.set_pitch(pitch)?; Ok(self) @@ -123,14 +122,14 @@ impl TTS { /** * Gets the current speech volume. - */ + */ pub fn get_volume(&self) -> Result { self.0.get_volume() } /** * Sets the desired speech volume. - */ + */ pub fn set_volume(&mut self, volume: u8) -> Result<&Self, Error> { self.0.set_volume(volume)?; Ok(self)