1
Fork 0

Add an ItemModifier syntax extension type

Where ItemDecorator creates new items given a single item, ItemModifier
alters the tagged item in place. The expansion rules for this are a bit
weird, but I think are the most reasonable option available.

When an item is expanded, all ItemModifier attributes are stripped from
it and the item is folded through all ItemModifiers. At that point, the
process repeats until there are no ItemModifiers in the new item.
This commit is contained in:
Steven Fackler 2014-02-27 23:49:25 -08:00
parent 294d3ddb89
commit eb4cbd55a8
5 changed files with 101 additions and 14 deletions

View file

@ -108,6 +108,21 @@ impl<T: Clone> Vec<T> {
}
*self.get_mut(index) = val;
}
pub fn partitioned(&self, f: |&T| -> bool) -> (Vec<T>, Vec<T>) {
let mut lefts = Vec::new();
let mut rights = Vec::new();
for elt in self.iter() {
if f(elt) {
lefts.push(elt.clone());
} else {
rights.push(elt.clone());
}
}
(lefts, rights)
}
}
impl<T:Clone> Clone for Vec<T> {