Skip to content

Instantly share code, notes, and snippets.

@meh
Created December 22, 2016 02:03
Show Gist options
  • Save meh/4a14ca6811634d019e676da3080afa9e to your computer and use it in GitHub Desktop.
Save meh/4a14ca6811634d019e676da3080afa9e to your computer and use it in GitHub Desktop.
named!(parse<Database>,
do_parse!(
tag!(&[0x1A, 0x01]) >>
name_section: le_i16 >>
boolean_section: le_i16 >>
number_section: le_i16 >>
string_offsets: le_i16 >>
string_section: le_i16 >>
names: flat_map!(take!(name_section),
take_until!("\x00")) >>
vvvvvvv
boolean: flat_map!(take!(boolean_section),
many0!(alt!(
tag!(&[0]) => { |_| false } |
tag!(&[1]) => { |_| true }))) >>
^^^^^^^^
(Database {
names: names,
boolean: boolean,
number: Vec::new(),
string: Vec::new(),
})));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment