salsa/examples/selection/util2.rs
Niko Matsakis 2e9b418bbb rework book a little bit
- extend some of the empty sections, add a new common pattern
- also, show how to use anchors and include so we can test the sources
  for common patterns
2019-09-24 06:13:51 -04:00

21 lines
490 B
Rust

use super::*;
// ANCHOR: util2
#[salsa::query_group(Request)]
trait RequestUtil: RequestParser {
fn header(&self) -> Vec<ParsedHeader>;
fn content_type(&self) -> Option<String>;
}
fn header(db: &impl RequestUtil) -> Vec<ParsedHeader> {
db.parse().header.clone()
}
fn content_type(db: &impl RequestUtil) -> Option<String> {
db.header()
.iter()
.find(|header| header.key == "content-type")
.map(|header| header.value.clone())
}
// ANCHOR_END: util2