Created
January 25, 2022 10:35
-
-
Save nanpuyue/2798c214a97b0c017074e26ca24e59ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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