Skip to content
Permalink
Browse files

task_state: Generate the list of task types

Also fix warnings.
  • Loading branch information
kmcallister committed Oct 24, 2014
1 parent 4923448 commit 4dee8ecdf09af1d3e2650b22e3bac02cc3107900
Showing with 10 additions and 10 deletions.
  1. +10 −10 components/util/task_state.rs
@@ -27,29 +27,29 @@ bitflags! {
}
}

// Exactly one of these should be set.
static task_types: &'static [TaskState]
= &[Script, Layout, Render];

macro_rules! predicates ( ( $( $f:ident = $c:ident ; )* ) => (
macro_rules! task_types ( ( $( $fun:ident = $flag:ident ; )* ) => (
impl TaskState {
$(
pub fn $f(self) -> bool {
self.contains($c)
pub fn $fun(self) -> bool {
self.contains($flag)
}
)*
}

#[cfg(not(ndebug))]
static TYPES: &'static [TaskState]
= &[ $( $flag ),* ];
))

predicates! {
task_types! {
is_script = Script;
is_layout = Layout;
is_render = Render;
}

#[cfg(not(ndebug))]
mod imp {
use super::{TaskState, task_types};
use super::{TaskState, TYPES};

local_data_key!(STATE: TaskState)

@@ -68,7 +68,7 @@ mod imp {
};

// Exactly one of the task type flags should be set.
assert_eq!(1, task_types.iter().filter(|&&ty| state.contains(ty)).count());
assert_eq!(1, TYPES.iter().filter(|&&ty| state.contains(ty)).count());
state
}

0 comments on commit 4dee8ec

Please sign in to comment.
You can’t perform that action at this time.