tesselode / kira

Library for expressive game audio.
https://crates.io/crates/kira
Apache License 2.0
837 stars 42 forks source link

Can't complie examples #22

Closed Chris1717 closed 2 years ago

Chris1717 commented 2 years ago

Hi, I'm new to Rust and would need audio playback for my project. I can't compile your examples. Can you please help me? Thanks.

error[E0061]: this function takes 1 argument but 2 arguments were supplied --> src/main.rs:15:19 15 let mut manager = AudioManager::new( ^^^^^^^^^^^^^^^^^ expected 1 argument 16 CpalBackend::new()?,
17 AudioManagerSettings::default(),
------------------------------- supplied 2 arguments

note: associated function defined here --> /Users/christian/.cargo/registry/src/github.com-1ecc6299db9ec823/kira-0.5.3/src/manager/mod.rs:143:9 | 143 | pub fn new(settings: AudioManagerSettings) -> Result<Self, SetupError> { | ^^^

error[E0277]: the ? operator can only be used in a function that returns Result or Option (or another type that implements FromResidual) --> src/main.rs:16:23 8 / fn abc() { 9 extern crate kira; 10 extern crate kira_cpal; 11 extern crate kira_loaders; ... 16 CpalBackend::new()?, ^ cannot use the ? operator in a function that returns () ... 19 Result::<(), Box>::Ok(()) 20 } _- this function should return Result or Option to accept ?

= help: the trait FromResidual<Result<Infallible, DeviceSetupError>> is not implemented for ()

error[E0277]: the ? operator can only be used in a function that returns Result or Option (or another type that implements FromResidual) --> src/main.rs:18:2 8 / fn abc() { 9 extern crate kira; 10 extern crate kira_cpal; 11 extern crate kira_loaders; ... 18 )?; ^ cannot use the ? operator in a function that returns () 19 Result::<(), Box>::Ok(()) 20 } _- this function should return Result or Option to accept ?

= help: the trait FromResidual<Result<Infallible, SetupError>> is not implemented for ()

error[E0308]: mismatched types --> src/main.rs:19:1 19 Result::<(), Box>::Ok(()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found enum Result
= note: expected unit type () found enum Result<(), Box<dyn std::error::Error>> help: consider using a semicolon here 19 Result::<(), Box>::Ok(()); + help: try adding a return type
8 fn abc() -> Result<(), Box> {
+++++++++++++++++++++++++++++++++++++++++
tesselode commented 2 years ago

Hi, the book is for Kira v0.6, which is in beta. I'll add a message to the readme to make that more clear.

Edit: readme updated. If you have any other issues, let me know!