4 // ignore-asmjs wasm2js does not support source maps yet
6 #[derive(PartialEq, Eq)]
9 #[derive(PartialEq, Eq)]
17 #[derive(PartialEq, Eq)]
19 bar
: Option
<Direction
>,
23 #[derive(PartialEq, Eq)]
24 enum EnumWithStructVariants
{
31 const TRUE_TRUE
: (bool
, bool
) = (true, true);
32 const NONE
: Option
<Direction
> = None
;
33 const EAST
: Direction
= Direction
::East
;
34 const NEW_FALSE
: NewBool
= NewBool(false);
35 const STATIC_FOO
: Foo
= Foo { bar: Some(Direction::South), baz: NEW_FALSE }
;
36 const VARIANT2_NORTH
: EnumWithStructVariants
= EnumWithStructVariants
::Variant2
{
37 dir
: Direction
::North
};
40 #[derive(Copy, Clone, PartialEq, Eq)]
41 pub struct InputState(usize);
43 pub const RELEASE
: InputState
= InputState(0);
44 pub const PRESS
: InputState
= InputState(1);
45 pub const REPEAT
: InputState
= InputState(2);
49 fn action_to_str(state
: glfw
::InputState
) -> &'
static str {
50 use glfw
::{RELEASE, PRESS, REPEAT}
;
52 RELEASE
=> { "Released" }
53 PRESS
=> { "Pressed" }
54 REPEAT
=> { "Repeated" }
59 assert_eq
!(action_to_str(glfw
::RELEASE
), "Released");
60 assert_eq
!(action_to_str(glfw
::PRESS
), "Pressed");
61 assert_eq
!(action_to_str(glfw
::REPEAT
), "Repeated");
65 const VAL
: [u8; 1] = [0];
67 VAL
=> unreachable
!(),
73 type Foo
= (i32, i32);
74 const ON
: Foo
= (1, 1);
75 const OFF
: Foo
= (0, 0);
78 OFF
=> unreachable
!(),
83 #[derive(PartialEq, Eq)]
84 enum C { D = 3, E = 4 }
87 assert_eq
!(match C
::D { F => 1, _ => 2, }
, 1);
90 #[derive(PartialEq, Eq)]
91 enum G { H = 3, I = 5 }
94 assert_eq
!(match G
::I { K => 1, _ => 2, }
, 1);
98 #[derive(PartialEq, Eq)]
100 const B
: A
= A
::AA(());
109 #[derive(PartialEq, Eq)]
114 const FOO
: Flags
= Flags { bits: 0x01 }
;
115 const BAR
: Flags
= Flags { bits: 0x02 }
;
116 match (Flags { bits: 0x02 }
) {
117 FOO
=> unreachable
!(),
124 assert_eq
!(match (true, false) {
131 assert_eq
!(match Some(Some(Direction
::North
)) {
133 Some(Some(Direction
::North
)) => 2,
134 Some(Some(EAST
)) => 3,
135 Some(Some(Direction
::South
)) => 4,
136 Some(Some(Direction
::West
)) => 5,
140 assert_eq
!(match (Foo { bar: Some(Direction::West), baz: NewBool(true) }
) {
141 Foo { bar: None, baz: NewBool(true) }
=> 1,
142 Foo { bar: NONE, baz: NEW_FALSE }
=> 2,
144 Foo { bar: _, baz: NEW_FALSE }
=> 4,
145 Foo { bar: Some(Direction::West), baz: NewBool(true) }
=> 5,
146 Foo { bar: Some(Direction::South), baz: NewBool(true) }
=> 6,
147 Foo { bar: Some(EAST), .. }
=> 7,
148 Foo { bar: Some(Direction::North), baz: NewBool(true) }
=> 8
151 assert_eq
!(match (EnumWithStructVariants
::Variant2 { dir: Direction::North }
) {
152 EnumWithStructVariants
::Variant1(true) => 1,
153 EnumWithStructVariants
::Variant1(false) => 2,
154 EnumWithStructVariants
::Variant2 { dir: Direction::West }
=> 3,
156 EnumWithStructVariants
::Variant2 { dir: Direction::South }
=> 5,
157 EnumWithStructVariants
::Variant2 { dir: Direction::East }
=> 6