Main crate example doesn't compile
From https://docs.rs/cpal/latest/cpal/:
use cpal::Data;
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
let stream = device.build_output_stream(
&config,
move |data: &mut [f32], _: &cpal::OutputCallbackInfo| {
// react to stream events and read or write stream data here.
},
move |err| {
// react to errors here.
},
None // None=blocking, Some(Duration)=timeout
);
This didn't compile for me until I changed &config to &config.into() just like in the examples.
PRs to fix the docs are welcome!
Is there a way to make the example code part of the CI so we don't get regressions?
Yeah one can use doctests for that. Right now the relevant code sections are tagged with no_run, which should already catch the issue, but I suppose that CI doesn't run doctests right now. I think it might make sense to first focus on fixing the examples, and then make a second PR to add running doctests to CI (apparently they are not).
The rustdoc actually compiles the test just fine and is already in CI, but only because it actually has the .into() in a hidden line. It's in line 62 of lib.rs. Here's the full example, omitting the //!.
use cpal::Data;
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
# let host = cpal::default_host();
# let device = host.default_output_device().unwrap();
# let config = device.default_output_config().unwrap().into();
let stream = device.build_output_stream(
&config,
move |data: &mut [f32], _: &cpal::OutputCallbackInfo| {
// react to stream events and read or write stream data here.
},
move |err| {
// react to errors here.
},
None // None=blocking, Some(Duration)=timeout
);