Skip to content

Commit

Permalink
Add test for generics with lifetimes
Browse files Browse the repository at this point in the history
Signed-off-by: Ahmed Abdelraoof <[email protected]>
  • Loading branch information
oddcoder committed Aug 14, 2024
1 parent 5405255 commit d17ca17
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions safe-discriminant/tests/pass/generics_with_lifetimes_enum.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use safe_discriminant::Discriminant;

// TODO
// pub enum Foo<'a, T: 'a> will not work

#[derive(Discriminant)]
#[repr(i64)]
pub enum Foo<'a, T>
where
T: 'a,
{
A(T) = 1,
B(&'a str) = -1,
}

fn main() {
let a = Foo::A(1);
let b: Foo<'_, u8> = Foo::B("hello world");
assert_eq!(a.discriminant(), 1);
assert_eq!(b.discriminant(), -1);
}

0 comments on commit d17ca17

Please sign in to comment.