Skip to content

Instantly share code, notes, and snippets.

@Yatekii
Created June 8, 2020 19:59
Show Gist options
  • Save Yatekii/7bc9b3392cfa8a3df996a7b678b57b4b to your computer and use it in GitHub Desktop.
Save Yatekii/7bc9b3392cfa8a3df996a7b678b57b4b to your computer and use it in GitHub Desktop.
error[E0597]: `modbus` does not live long enough
--> src/lib.rs:302:9
|
302 | modbus.on_data_received(&[0x42, 0x42]);
| ^^^^^^ borrowed value does not live long enough
303 | modbus.next().await;
304 | }
| -
| |
| `modbus` dropped here while still borrowed
| borrow might be used here, when `modbus` is dropped and runs the destructor for type `Modbus<'_, typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UTerm, typenum::bit::B1>, typenum::bit::B0>, typenum::bit::B0>, typenum::bit::B0>, typenum::bit::B0>, typenum::bit::B0>, typenum::bit::B0>, typenum::bit::B0>, typenum::bit::B0>, typenum::bit::B0>, typenum::bit::B0>, typenum::bit::B0>>`
error[E0499]: cannot borrow `modbus` as mutable more than once at a time
--> src/lib.rs:303:9
|
302 | modbus.on_data_received(&[0x42, 0x42]);
| ------ first mutable borrow occurs here
303 | modbus.next().await;
| ^^^^^^
| |
| second mutable borrow occurs here
| first borrow later used here
error: aborting due to 2 previous errors; 1 warning emitted
async fn test() {
println!("Hello, world!");
let bb = bbqueue::BBBuffer::<bbqueue::atomic::consts::U2048>::new();
let mut modbus = super::Modbus::new(&bb);
modbus.on_data_received(&[0x42, 0x42]);
modbus.next().await;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment