Skip to content

Instantly share code, notes, and snippets.

@awelkie
Created December 20, 2015 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awelkie/88f6267b89ea998f3bb3 to your computer and use it in GitHub Desktop.
Save awelkie/88f6267b89ea998f3bb3 to your computer and use it in GitHub Desktop.
PhantomRef
[package]
name = "usb_example"
version = "0.1.0"
authors = ["Allen Welkie <allen.welkie@gmail.com>"]
[dependencies]
libusb = "*"
extern crate libusb;
struct Combined<'a> {
ctx: libusb::Context,
dev: libusb::Device<'a>,
}
fn get_device<'a>() -> Combined<'a> {
let mut ctx = libusb::Context::new().unwrap();
let dev = ctx.devices().unwrap().iter().next().unwrap();
Combined { ctx: ctx, dev: dev, }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment