Skip to content

Instantly share code, notes, and snippets.

@nanpuyue
Created January 25, 2022 10:35
Show Gist options
  • Save nanpuyue/2798c214a97b0c017074e26ca24e59ad to your computer and use it in GitHub Desktop.
Save nanpuyue/2798c214a97b0c017074e26ca24e59ad to your computer and use it in GitHub Desktop.
use std::marker::PhantomData;
#[derive(Debug)]
struct S<'a> {
_pd: PhantomData<&'a mut &'a ()>
}
impl<'a> Drop for S<'a> { fn drop(&mut self) {} }
impl<'a> S<'a> {
fn feed(&self, data: &'a [u8]) {
drop(data);
}
}
fn main() {
let data = vec![];
let s = S { _pd: PhantomData };
// let data = vec![];
s.feed(&data);
dbg!(&s);
drop(s);
drop(data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment