Created
January 9, 2022 17:04
-
-
Save mheiber/ae5751cced189ddd532b740ef725b644 to your computer and use it in GitHub Desktop.
hrtb
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
trait A {} | |
struct SasA{} | |
impl A for SasA {} | |
trait Db<'d> { | |
type Mem: ?Sized + A + 'd; | |
fn d(&self) -> &Self::Mem; | |
} | |
trait Trait: for<'d> Db<'d> { | |
} | |
struct D { | |
} | |
impl<'d> Db<'d> for D { | |
type Mem = dyn A + 'd; | |
fn d(&self) -> &Self::Mem { | |
Box::leak(Box::new(SasA{})) | |
} | |
} | |
fn main() { | |
let d = D{}; | |
<D as Db>::d(&d); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment