From: Scott Worley Date: Sun, 1 Jan 2023 09:24:41 +0000 (-0800) Subject: Appease clippy more X-Git-Tag: v0.3.0~7 X-Git-Url: http://git.scottworley.com/voter/commitdiff_plain/518c108c3a580fa0dbaaec1c03c7fc7744240297?hp=2da08b8426e7c40f594cbdfc751ae39ed78d622e Appease clippy more --- diff --git a/src/main.rs b/src/main.rs index 2e5de54..ef09e31 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,7 +40,7 @@ fn get_voter(request: &cgi::Request) -> Result<&[u8], cgi::Response> { let cookie = request .headers() .get(cgi::http::header::COOKIE) - .map(|c| c.as_bytes()) + .map(cgi::http::HeaderValue::as_bytes) .and_then(|c| c.strip_prefix(COOKIE_NAME)) .and_then(|c| c.strip_prefix(b"=")) .ok_or_else(|| cgi::text_response(400, "Invalid cookie"))?; @@ -83,9 +83,8 @@ fn valid_id_char(c: &u8) -> bool { fn make_random_id() -> [u8; COOKIE_LENGTH] { let mut id = [0; COOKIE_LENGTH]; - for c in id.iter_mut() { - while !valid_id_char(c) - { + for c in &mut id { + while !valid_id_char(c) { *c = random() } } @@ -193,8 +192,7 @@ const HTML_FOOTER: &str = " fn supports(tally: &HashMap>, me: &str, candidate: &str) -> bool { tally .get(candidate) - .map(|supporters| supporters.contains(me)) - .unwrap_or(false) + .map_or(false, |supporters| supporters.contains(me)) } fn prompt_for_vote(dir: PathBuf, request: cgi::Request) -> Result { @@ -213,11 +211,8 @@ fn prompt_for_vote(dir: PathBuf, request: cgi::Request) -> Result