Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mtthw-meyer/a091e0adf5cd20d1880ebe82c9164a49 to your computer and use it in GitHub Desktop.
Save mtthw-meyer/a091e0adf5cd20d1880ebe82c9164a49 to your computer and use it in GitHub Desktop.
pub struct Audio {
pub stream: sai::Sai<stm32::SAI1, sai::I2S>,
input: &'static mut IoBuffer,
output: &'static mut IoBuffer,
}
impl Audio {
pub fn new(
mut stream: sai::Sai<stm32::SAI1, sai::I2S>,
input: &'static mut IoBuffer,
output: &'static mut IoBuffer,
) -> Self {
stream.listen(SaiChannel::ChannelB, Event::Data);
stream.enable();
stream.try_send(0, 0).unwrap();
Audio {
stream,
input,
output,
}
}
pub fn get_lifetime_errors(&mut self) -> &'static [u32] {
&self.input[..2]
}
}
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter in function call due to conflicting requirements
--> src/audio.rs:67:10
|
67 | &self.input[..2]
| ^^^^^^^^^^^^^^^
|
note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the method body at 66:5...
--> src/audio.rs:66:5
|
66 | / pub fn get_lifetime_errors(&mut self) -> &'static [u32] {
67 | | &self.input[..2]
68 | | }
| |_____^
note: ...so that reference does not outlive borrowed content
--> src/audio.rs:67:10
|
67 | &self.input[..2]
| ^^^^^^^^^^
= note: but, the lifetime must be valid for the static lifetime...
note: ...so that reference does not outlive borrowed content
--> src/audio.rs:67:9
|
67 | &self.input[..2]
| ^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0495`.
error: could not compile `libdaisy-rust`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment