mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-18 10:35:23 +00:00
api_client: use Option::map in get_header
It's more idiomatic Rust, and satisfies nightly clippy. Signed-off-by: Gaelan Steele <gbs@canishe.com>
This commit is contained in:
parent
d8e1898b46
commit
7a18e247f4
@ -76,11 +76,8 @@ impl StatusCode {
|
|||||||
|
|
||||||
fn get_header<'a>(res: &'a str, header: &'a str) -> Option<&'a str> {
|
fn get_header<'a>(res: &'a str, header: &'a str) -> Option<&'a str> {
|
||||||
let header_str = format!("{}: ", header);
|
let header_str = format!("{}: ", header);
|
||||||
if let Some(o) = res.find(&header_str) {
|
res.find(&header_str)
|
||||||
Some(&res[o + header_str.len()..o + res[o..].find('\r').unwrap()])
|
.map(|o| &res[o + header_str.len()..o + res[o..].find('\r').unwrap()])
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_status_code(res: &str) -> Result<StatusCode, Error> {
|
fn get_status_code(res: &str) -> Result<StatusCode, Error> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user