Skip to content

Commit d17ca17

Browse files
committed
Add test for generics with lifetimes
Signed-off-by: Ahmed Abdelraoof <[email protected]>
1 parent 5405255 commit d17ca17

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use safe_discriminant::Discriminant;
2+
3+
// TODO
4+
// pub enum Foo<'a, T: 'a> will not work
5+
6+
#[derive(Discriminant)]
7+
#[repr(i64)]
8+
pub enum Foo<'a, T>
9+
where
10+
T: 'a,
11+
{
12+
A(T) = 1,
13+
B(&'a str) = -1,
14+
}
15+
16+
fn main() {
17+
let a = Foo::A(1);
18+
let b: Foo<'_, u8> = Foo::B("hello world");
19+
assert_eq!(a.discriminant(), 1);
20+
assert_eq!(b.discriminant(), -1);
21+
}

0 commit comments

Comments
 (0)