Skip to content

Instantly share code, notes, and snippets.

@Geobert
Created August 20, 2018 12:33
Show Gist options
  • Save Geobert/05d3ae9e474642ba27bdd55aa009180f to your computer and use it in GitHub Desktop.
Save Geobert/05d3ae9e474642ba27bdd55aa009180f to your computer and use it in GitHub Desktop.
pub struct UsbContext {
api: hidapi::HidApi,
}
impl UsbContext {
pub fn new() -> UsbContext {
UsbContext {
api: hidapi::HidApi::new().unwrap()
}
}
}
fn this_works() {
{
let usb = UsbContext::new();
// my code to switch mode
}
let usb = UsbContext::new();
// code to send msg
}
fn this_fails() {
let usb = UsbContext::new();
// my code to switch mode
// code to send msg
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment