Skip to content

Commit 1f0fabb

Browse files
committed
use to_string instead of format! and change UnsupportedDuplexStream to unit struct rather than making it defensive for future field addition
1 parent 28198e3 commit 1f0fabb

2 files changed

Lines changed: 7 additions & 14 deletions

File tree

src/duplex.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -259,23 +259,16 @@ impl DuplexStreamConfig {
259259
/// This type implements `StreamTrait` but all operations return errors.
260260
/// Backend implementations should replace this with their own type once
261261
/// duplex support is implemented.
262-
pub struct UnsupportedDuplexStream {
263-
_private: (),
264-
}
262+
#[derive(Default)]
263+
pub struct UnsupportedDuplexStream;
265264

266265
impl UnsupportedDuplexStream {
267266
/// Create a new unsupported duplex stream marker.
268267
///
269268
/// This should not normally be called - it exists only to satisfy
270269
/// type requirements for backends without duplex support.
271270
pub fn new() -> Self {
272-
Self { _private: () }
273-
}
274-
}
275-
276-
impl Default for UnsupportedDuplexStream {
277-
fn default() -> Self {
278-
Self::new()
271+
Self
279272
}
280273
}
281274

src/host/coreaudio/macos/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ impl StreamInner {
187187
fn play(&mut self) -> Result<(), PlayStreamError> {
188188
if !self.playing {
189189
if let Err(e) = self.audio_unit.start() {
190-
let description = format!("{e}");
190+
let description = e.to_string();
191191
let err = BackendSpecificError { description };
192192
return Err(err.into());
193193
}
@@ -199,7 +199,7 @@ impl StreamInner {
199199
fn pause(&mut self) -> Result<(), PauseStreamError> {
200200
if self.playing {
201201
if let Err(e) = self.audio_unit.stop() {
202-
let description = format!("{e}");
202+
let description = e.to_string();
203203
let err = BackendSpecificError { description };
204204
return Err(err.into());
205205
}
@@ -288,7 +288,7 @@ impl DuplexStreamInner {
288288
fn play(&mut self) -> Result<(), PlayStreamError> {
289289
if !self.playing {
290290
if let Err(e) = self.audio_unit.start() {
291-
let description = format!("{e}");
291+
let description = e.to_string();
292292
let err = BackendSpecificError { description };
293293
return Err(err.into());
294294
}
@@ -300,7 +300,7 @@ impl DuplexStreamInner {
300300
fn pause(&mut self) -> Result<(), PauseStreamError> {
301301
if self.playing {
302302
if let Err(e) = self.audio_unit.stop() {
303-
let description = format!("{e}");
303+
let description = e.to_string();
304304
let err = BackendSpecificError { description };
305305
return Err(err.into());
306306
}

0 commit comments

Comments
 (0)