Skip to content

Instantly share code, notes, and snippets.

@endor
Created January 8, 2019 08:49
Show Gist options
  • Save endor/38e6c585942c906d30579a138c85917e to your computer and use it in GitHub Desktop.
Save endor/38e6c585942c906d30579a138c85917e to your computer and use it in GitHub Desktop.
test.rs
let mut all_suites: Vec<Suite> = Vec::new();
let mut default_suite = Suite {
children: vec![],
name: "".to_string(),
status: "fail".to_string(),
};
let mut current_suite: &mut Suite = &mut default_suite;
loop {
match reader.read_event(&mut buf) {
Ok(Event::Start(ref e)) if e.name() == b"status" => {
let suite_status = string_attribute(e.attributes(), "status");
current_suite.status = suite_status.to_lowercase();
},
Ok(Event::Start(ref e)) if e.name() == b"suite" => {
let name = string_attribute(e.attributes(), "name");
let suite = Suite {
children: vec![],
name: name.clone(),
status: "fail".to_string(),
};
all_suites.push(suite);
all_suites.last_mut().map(|s| {
current_suite = s;
});
},
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment