Closed
Description
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Key {
AltArrow(Arrow),
Arrow(Arrow),
Ctrl(char),
Char(char),
Esc,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Arrow { Left, Right, Up, Down }
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Event {
Key(Key),
String(String),
Resize,
Unknown(Vec<u8>),
}
static XTERM_SINGLE_BYTES : [(u8, Event); 5] =
[ (1, Event::Key(Key::Ctrl('a'))),
(5, Event::Key(Key::Ctrl('e'))),
(23, Event::Key(Key::Ctrl('w'))),
(11, Event::Key(Key::Ctrl('k'))),
(4, Event::Key(Key::Ctrl('d'))),
];
fn main() {
println!("{:?}", XTERM_SINGLE_BYTES);
}
(can be tested here: https://is.gd/EkJ3by)
When run with beta or nightly, this program segfaults.
I tried to simplify this a little bit, but my attempts either turned segfault into a stack overflow, or made it working. Here are some changes I've tried:
- I tried
[(u8, char)]
forXTERM_SINGLE_BYTES
and it worked fine. - I tried removing
Event::Key
s (e.g.[(u8, Key)]
) and it worked. - I removed some of the constructors from
Event
enum, most of the time the error turned into a stack overflow.
In my original program I'm iterating the array, and for the u8
part I'm getting random bytes instead of bytes I put in the array. I'm using rustc 1.13.0-nightly (70598e0 2016-09-03).