From 22461a44740b85351cf306cb205c9c2816b72add Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Sun, 24 Apr 2022 00:05:35 +0200 Subject: [PATCH] yeah --- src/lib.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 125e07a..9026cb3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,22 +6,20 @@ pub trait CoolTrait {} // implement that trait for all reference to someone implementing the trait impl<'a, D: CoolTrait> CoolTrait for &'a D {} -// a type with a lifetime that contains two other types -pub enum Parent<'a> { - A(Box>), - B(Box>), +// a type with a lifetime +pub struct Parent<'a> { // We need a lifetime. otherwise, if we remove it, we get: // error[E0275]: overflow evaluating the requirement `A: CoolTrait` - Boo(PhantomData<&'a ()>) + _boo: PhantomData<&'a ()>, } -// those two types that in turn contain the parent type recursively +// two more types with a lifetime pub struct A<'a> { - parent: Parent<'a>, + _boo: PhantomData<&'a ()>, } pub struct B<'a> { - parent: Parent<'a>, + _boo: PhantomData<&'a ()>, } // implement CoolTrait only when the two types themselves implement it