RustAudio / rodio

Rust audio playback library
Apache License 2.0
1.74k stars 228 forks source link

Bug: Tests and Examples error #573

Closed DivineGod closed 5 months ago

DivineGod commented 5 months ago

Examples and tests are broken since 77c5c54 introduced in PR https://github.com/RustAudio/rodio/pull/550

Error output:

ᚦ cargo run --example spatial
   Compiling rodio v0.17.3 (/Users/dg/code/rodio)
error[E0382]: use of moved value: `sf`
   --> src/stream.rs:353:26
    |
348 |     Ok(supported.into_iter().flat_map(|sf| {
    |                                        -- move occurs because `sf` has type `SupportedStreamConfigRange`, which does not implement the `Copy` trait
...
351 |         let mut formats = vec![sf.with_max_sample_rate()];
    |                                   ---------------------- `sf` moved due to this method call
352 |         if HZ_44100 < max_rate && HZ_44100 > min_rate {
353 |             formats.push(sf.with_sample_rate(HZ_44100))
    |                          ^^ value used here after move
    |
note: `SupportedStreamConfigRange::with_max_sample_rate` takes ownership of the receiver `self`, which moves `sf`
   --> /Users/dg/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cpal-0.15.2/src/lib.rs:650:33
    |
650 |     pub fn with_max_sample_rate(self) -> SupportedStreamConfig {
    |                                 ^^^^
help: you can `clone` the value and consume it, but this might not be your desired behavior
    |
351 |         let mut formats = vec![sf.clone().with_max_sample_rate()];
    |                                  ++++++++

error[E0382]: use of moved value: `sf`
   --> src/stream.rs:355:22
    |
348 |     Ok(supported.into_iter().flat_map(|sf| {
    |                                        -- move occurs because `sf` has type `SupportedStreamConfigRange`, which does not implement the `Copy` trait
...
351 |         let mut formats = vec![sf.with_max_sample_rate()];
    |                                   ---------------------- `sf` moved due to this method call
352 |         if HZ_44100 < max_rate && HZ_44100 > min_rate {
353 |             formats.push(sf.with_sample_rate(HZ_44100))
    |                             -------------------------- `sf` moved due to this method call
354 |         }
355 |         formats.push(sf.with_sample_rate(min_rate));
    |                      ^^ value used here after move
    |
note: `SupportedStreamConfigRange::with_sample_rate` takes ownership of the receiver `self`, which moves `sf`
   --> /Users/dg/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cpal-0.15.2/src/lib.rs:638:29
    |
638 |     pub fn with_sample_rate(self, sample_rate: SampleRate) -> SupportedStreamConfig {
    |                             ^^^^
help: you can `clone` the value and consume it, but this might not be your desired behavior
    |
351 |         let mut formats = vec![sf.clone().with_max_sample_rate()];
    |                                  ++++++++
help: you can `clone` the value and consume it, but this might not be your desired behavior
    |
353 |             formats.push(sf.clone().with_sample_rate(HZ_44100))
    |                            ++++++++
dvdsk commented 5 months ago

Good catch, can not reproduce on my sys but #574 should fix it. Can you confirm that on your side?

DivineGod commented 5 months ago

Can confirm #574 does indeed fix this.