File: test.rs

package info (click to toggle)
rust-typeid 1.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 120 kB
  • sloc: makefile: 4
file content (25 lines) | stat: -rw-r--r-- 854 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#[test]
fn test_non_static_type_id() {
    assert_eq!(typeid::of::<usize>(), typeid::of::<usize>());
    assert_eq!(typeid::of::<&str>(), typeid::of::<&'static str>());

    assert_ne!(typeid::of::<u32>(), typeid::of::<[u8; 4]>());
    assert_ne!(typeid::of::<u32>(), typeid::of::<[u32; 2]>());

    assert_ne!(typeid::of::<usize>(), typeid::of::<isize>());
    assert_ne!(typeid::of::<usize>(), typeid::of::<&usize>());
    assert_ne!(typeid::of::<&usize>(), typeid::of::<&&usize>());
    assert_ne!(typeid::of::<&usize>(), typeid::of::<&mut usize>());

    assert_ne!(typeid::of::<fn(&str)>(), typeid::of::<fn(&'static str)>());

    trait Trait<'a> {}
    assert_ne!(
        typeid::of::<dyn for<'a> Trait<'a>>(),
        typeid::of::<dyn Trait<'static>>(),
    );

    struct A;
    struct B;
    assert_ne!(typeid::of::<A>(), typeid::of::<B>());
}