Loading RustViz Engine...
Parse HTTP raw headers into a slice of key-value borrowed pairs without String allocations.
This problem is currently in blueprint template mode. Once the concept foundation is finalized, live in-browser WebAssembly compilation and test assertion runners will be enabled here.
pub struct Header<'a> {
pub key: &'a str,
pub val: &'a str,
}
pub fn parse_headers<'a>(raw: &'a str) -> Vec<Header<'a>> {
raw.lines().filter_map(|line| {
let mut parts = line.splitn(2, ':');
let key = parts.next()?.trim();
let val = parts.next()?.trim();
Some(Header { key, val })
}).collect()
}