Skip to content

Instantly share code, notes, and snippets.

@nanpuyue
Created January 25, 2022 08:28
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 nanpuyue/df0b0c0386b8934d30af1b3d5b03b4a0 to your computer and use it in GitHub Desktop.
Save nanpuyue/df0b0c0386b8934d30af1b3d5b03b4a0 to your computer and use it in GitHub Desktop.
struct S<'a> {
a: &'a (),
}
impl<'a> S<'a> {
fn feed(&self, data: &'a [u8]) {
drop(data);
}
fn get_a(&self) -> &() {
self.a
}
}
fn main() {
let a = &();
let s = S { a };
let data = vec![b'x', b'x'];
s.feed(&data);
drop(data);
dbg!(s.get_a());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment