From 27428c95bc1d6c2064b5a3c1cf808a96be1228f2 Mon Sep 17 00:00:00 2001 From: Ethan Donowitz Date: Mon, 28 Feb 2022 16:55:01 +0000 Subject: [PATCH] chore: update to Rust 1.59 --- Dockerfile | 2 +- src/db/tests/db.rs | 26 +++++++++++++------------- src/tokenserver/extractors.rs | 4 ++-- src/web/extractors.rs | 2 +- src/web/handlers.rs | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index a5f4d99927..0bdce16358 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:1.58-buster as builder +FROM rust:1.59-buster as builder WORKDIR /app ADD . /app ENV PATH=$PATH:/root/.cargo/bin diff --git a/src/db/tests/db.rs b/src/db/tests/db.rs index 588afaada5..730eb5a1c9 100644 --- a/src/db/tests/db.rs +++ b/src/db/tests/db.rs @@ -132,7 +132,7 @@ async fn get_bsos_limit_offset() -> Result<()> { 0, Sorting::Index, 0, - &"0".to_owned(), + "0", )) .await?; assert!(bsos.items.is_empty()); @@ -147,7 +147,7 @@ async fn get_bsos_limit_offset() -> Result<()> { 0, Sorting::Index, -1, - &"0".to_owned(), + "0", )) .await?; assert_eq!(bsos.items.len(), size as usize); @@ -254,7 +254,7 @@ async fn get_bsos_newer() -> Result<()> { timestamp as u64 - 30, Sorting::Newest, 10, - &"0".to_owned(), + "0", )) .await?; assert_eq!(bsos.items.len(), 3); @@ -271,7 +271,7 @@ async fn get_bsos_newer() -> Result<()> { timestamp as u64 - 20, Sorting::Newest, 10, - &"0".to_owned(), + "0", )) .await?; assert_eq!(bsos.items.len(), 2); @@ -287,7 +287,7 @@ async fn get_bsos_newer() -> Result<()> { timestamp as u64 - 10, Sorting::Newest, 10, - &"0".to_owned(), + "0", )) .await?; assert_eq!(bsos.items.len(), 1); @@ -302,7 +302,7 @@ async fn get_bsos_newer() -> Result<()> { timestamp as u64, Sorting::Newest, 10, - &"0".to_owned(), + "0", )) .await?; assert_eq!(bsos.items.len(), 0); @@ -338,7 +338,7 @@ async fn get_bsos_sort() -> Result<()> { 0, Sorting::Newest, 10, - &"0".to_owned(), + "0", )) .await?; assert_eq!(bsos.items.len(), 3); @@ -355,7 +355,7 @@ async fn get_bsos_sort() -> Result<()> { 0, Sorting::Oldest, 10, - &"0".to_owned(), + "0", )) .await?; assert_eq!(bsos.items.len(), 3); @@ -372,7 +372,7 @@ async fn get_bsos_sort() -> Result<()> { 0, Sorting::Index, 10, - &"0".to_owned(), + "0", )) .await?; assert_eq!(bsos.items.len(), 3); @@ -550,7 +550,7 @@ async fn delete_collection_tombstone() -> Result<()> { assert!(result.is_none()); } // make sure coll BSOs were *not* deleted - let result = db.get_bso(gbso(uid, coll, &bid1.to_string())).await?; + let result = db.get_bso(gbso(uid, coll, bid1)).await?; assert!(result.is_some()); Ok(()) } @@ -887,7 +887,7 @@ async fn get_bsos() -> Result<()> { 0, Sorting::Newest, 10, - &"0".to_owned(), + "0", )) .await?; assert_eq!(ids.items, vec!["b0", "b1", "b2", "b3", "b4"]); @@ -901,7 +901,7 @@ async fn get_bsos() -> Result<()> { 0, Sorting::Newest, 10, - &"0".to_owned(), + "0", )) .await?; assert_eq!(bsos.items.len(), 3); @@ -918,7 +918,7 @@ async fn get_bsos() -> Result<()> { 0, Sorting::Index, 2, - &"0".to_owned(), + "0", )) .await?; assert_eq!(bsos.items.len(), 2); diff --git a/src/tokenserver/extractors.rs b/src/tokenserver/extractors.rs index c8d436250d..19200fea3d 100644 --- a/src/tokenserver/extractors.rs +++ b/src/tokenserver/extractors.rs @@ -315,7 +315,7 @@ impl FromRequest for TokenData { .map_err(|_| TokenserverError::unauthorized("Unauthorized"))?; // The request must use Bearer auth - if let Some((auth_type, _)) = authorization_header.split_once(" ") { + if let Some((auth_type, _)) = authorization_header.split_once(' ') { if auth_type.to_ascii_lowercase() != "bearer" { return Err(TokenserverError::unauthorized("Unsupported").into()); } @@ -381,7 +381,7 @@ impl FromRequest for KeyId { .map_err(|_| TokenserverError::invalid_key_id("Invalid X-KeyID header"))?; let (keys_changed_at_string, encoded_client_state) = x_key_id - .split_once("-") + .split_once('-') .ok_or_else(|| TokenserverError::invalid_credentials("Unauthorized"))?; let client_state = { diff --git a/src/web/extractors.rs b/src/web/extractors.rs index 4ab9535fee..0358560789 100644 --- a/src/web/extractors.rs +++ b/src/web/extractors.rs @@ -128,7 +128,7 @@ fn get_accepted(req: &HttpRequest, accepted: &[&str], default: &'static str) -> .partial_cmp(&a.quality) .unwrap_or(std::cmp::Ordering::Equal) }); - for qitem in candidates.to_vec() { + for qitem in candidates.iter().cloned() { if qitem.item == STAR_STAR { return default.to_owned(); } diff --git a/src/web/handlers.rs b/src/web/handlers.rs index ff4a0b9702..16279a1ea3 100644 --- a/src/web/handlers.rs +++ b/src/web/handlers.rs @@ -225,7 +225,7 @@ where .into_iter() .map(|v| serde_json::to_string(&v).unwrap_or_else(|_| "".to_string())) .filter(|v| !v.is_empty()) - .map(|v| v.replace("\n", "\\u000a") + "\n") + .map(|v| v.replace('\n', "\\u000a") + "\n") .collect(); Ok(resp