diff --git a/src/lib.rs b/src/lib.rs index 40546bd..0c31acc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -787,18 +787,18 @@ impl Game { /// # use cat_box::play; /// play("/path/to/song.mp3", 15); /// ``` -pub fn play>(path: P, time: u64) -> std::thread::JoinHandle> { +pub fn play + Send + 'static>( + path: P, + time: u64, +) -> std::thread::JoinHandle> { use std::fs::File; use std::io::BufReader; use std::thread; - // bypass the Send + 'static requirement - let p = path.as_ref(); - thread::spawn(move || { let (_stream, stream_handle) = OutputStream::try_default()?; // Load a sound from a file, using a path relative to Cargo.toml - let file = BufReader::new(File::open(p)?); + let file = BufReader::new(File::open(path)?); // Decode that sound file into a source let source = Decoder::new(file)?; // Play the sound directly on the device