From e5efa3f7d5279cffb68a01156a111b81beff2db3 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Sun, 9 Oct 2016 00:30:33 -0700 Subject: [PATCH] Make dependencies execute in order they appear It doesn't seem particularly valuable for dependencies to execute in any order, so make Recipe.dependencies a vec so they execute in order. --- justfile | 2 ++ src/lib.rs | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/justfile b/justfile index 948d8db..0443c64 100644 --- a/justfile +++ b/justfile @@ -24,6 +24,8 @@ create: clean: rm -r tmp +polyglot: python js perl sh ruby + python: #!/usr/bin/env python3 print('Hello from python!') diff --git a/src/lib.rs b/src/lib.rs index 356fe74..2249fb4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -50,7 +50,7 @@ pub struct Recipe<'a> { name: &'a str, leading_whitespace: &'a str, lines: Vec<&'a str>, - dependencies: BTreeSet<&'a str>, + dependencies: Vec<&'a str>, shebang: bool, } @@ -502,15 +502,15 @@ pub fn parse<'a>(text: &'a str) -> Result { } let rest = captures.at(2).unwrap().trim(); - let mut dependencies = BTreeSet::new(); + let mut dependencies = vec![]; for part in whitespace_re.split(rest) { if name_re.is_match(part) { - if dependencies.contains(part) { + if dependencies.contains(&part) { return Err(error(text, i, ErrorKind::DuplicateDependency{ name: part, })); } - dependencies.insert(part); + dependencies.push(part); } else { return Err(error(text, i, ErrorKind::UnparsableDependencies)); }