salsa/examples/selection/util1.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

16 lines
373 B
Rust

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