summaryrefslogtreecommitdiff
path: root/abnf_to_pest
diff options
context:
space:
mode:
authorNadrieril2019-04-15 17:43:39 +0200
committerNadrieril2019-04-15 17:43:39 +0200
commit6ef11130281a16e5ca23250ac78bcd27c777a14e (patch)
tree95c60869904bb858f0ea31aba6a21e81faafe0d2 /abnf_to_pest
parent52615794bfe69a3ad14bff0044ade776028c08cd (diff)
Keep rule order in `abnf_to_pest`
Closes #79
Diffstat (limited to 'abnf_to_pest')
-rw-r--r--abnf_to_pest/Cargo.toml1
-rw-r--r--abnf_to_pest/src/lib.rs4
2 files changed, 3 insertions, 2 deletions
diff --git a/abnf_to_pest/Cargo.toml b/abnf_to_pest/Cargo.toml
index fc9fe66..cd6aa10 100644
--- a/abnf_to_pest/Cargo.toml
+++ b/abnf_to_pest/Cargo.toml
@@ -10,5 +10,6 @@ doctest = false
[dependencies]
abnf = "0.1.2"
+indexmap = "1.0.2"
itertools = "0.8.0"
pretty = "0.5.2"
diff --git a/abnf_to_pest/src/lib.rs b/abnf_to_pest/src/lib.rs
index 46bd79d..f1a167f 100644
--- a/abnf_to_pest/src/lib.rs
+++ b/abnf_to_pest/src/lib.rs
@@ -8,7 +8,7 @@ pub use abnf::abnf::{
};
use itertools::Itertools;
use pretty::{BoxDoc, Doc};
-use std::collections::HashMap;
+use indexmap::map::IndexMap;
trait Pretty {
fn pretty(&self) -> Doc<'static, BoxDoc<'static, ()>>;
@@ -146,7 +146,7 @@ impl Pretty for (String, PestyRule) {
/// Parse an abnf file. Returns a map of rules.
pub fn parse_abnf(
data: &[u8],
-) -> Result<HashMap<String, PestyRule>, std::io::Error> {
+) -> Result<IndexMap<String, PestyRule>, std::io::Error> {
let make_err =
|e| std::io::Error::new(std::io::ErrorKind::Other, format!("{}", e));
let rules: Vec<Rule> =