diff --git a/cargo-registry/src/client.rs b/cargo-registry/src/client.rs index 49a378839e8b5d..17432f0ebe27cd 100644 --- a/cargo-registry/src/client.rs +++ b/cargo-registry/src/client.rs @@ -23,16 +23,14 @@ pub struct ClientConfig<'a>(pub ProgramV4CommandConfig<'a>); impl<'a> ClientConfig<'a> { pub fn new(client: &'a Client) -> Self { - Self { - 0: ProgramV4CommandConfig { - websocket_url: &client.websocket_url, - commitment: client.commitment, - payer: &client.cli_signers[0], - authority: &client.cli_signers[client.authority_signer_index], - output_format: &OutputFormat::Display, - use_quic: true, - }, - } + Self(ProgramV4CommandConfig { + websocket_url: &client.websocket_url, + commitment: client.commitment, + payer: &client.cli_signers[0], + authority: &client.cli_signers[client.authority_signer_index], + output_format: &OutputFormat::Display, + use_quic: true, + }) } } @@ -56,7 +54,7 @@ impl Client { config_path, ); - let default_signer = DefaultSigner::new(name, &default_signer_path); + let default_signer = DefaultSigner::new(name, default_signer_path); read_keypair_file(default_signer.path) } @@ -189,9 +187,8 @@ impl Client { let confirm_transaction_initial_timeout = Duration::from_secs(confirm_transaction_initial_timeout); - let payer_keypair = Self::get_keypair(&matches, &config.keypair_path, "keypair".as_ref())?; - let authority_keypair = - Self::get_keypair(&matches, &config.keypair_path, "authority".as_ref())?; + let payer_keypair = Self::get_keypair(&matches, &config.keypair_path, "keypair")?; + let authority_keypair = Self::get_keypair(&matches, &config.keypair_path, "authority")?; let port = value_t_or_exit!(matches, "port", u16); diff --git a/cargo-registry/src/main.rs b/cargo-registry/src/main.rs index 03b7daf525c4b1..f4723681ae716f 100644 --- a/cargo-registry/src/main.rs +++ b/cargo-registry/src/main.rs @@ -27,14 +27,14 @@ impl CargoRegistryService { fn error_response() -> hyper::Response { hyper::Response::builder() .status(hyper::StatusCode::OK) - .body(hyper::Body::from(format!("{}", "error"))) + .body(hyper::Body::from("error")) .unwrap() } fn success_response() -> hyper::Response { hyper::Response::builder() .status(hyper::StatusCode::OK) - .body(hyper::Body::from(format!("{}", "success"))) + .body(hyper::Body::from("success")) .unwrap() } @@ -51,9 +51,9 @@ impl CargoRegistryService { } fn get_crate_name_and_version(path: &str) -> Option<(&str, &str, &str)> { - path.rsplit_once("/").and_then(|(remainder, version)| { + path.rsplit_once('/').and_then(|(remainder, version)| { remainder - .rsplit_once("/") + .rsplit_once('/') .map(|(remainder, name)| (remainder, name, version)) }) } @@ -89,7 +89,7 @@ impl CargoRegistryService { } fn get_crate_name(path: &str) -> Option<(&str, &str)> { - path.rsplit_once("/") + path.rsplit_once('/') } fn handle_get_owners_request( @@ -169,12 +169,12 @@ impl CargoRegistryService { return Ok(Self::error_response()); } - let Some((path, endpoint)) = path.rsplit_once("/") else { + let Some((path, endpoint)) = path.rsplit_once('/') else { return Ok(Self::error_response()); }; - Ok(match request.method() { - &Method::PUT => match endpoint { + Ok(match *request.method() { + Method::PUT => match endpoint { "new" => { if path.len() != PATH_PREFIX.len() { Self::error_response() @@ -186,12 +186,12 @@ impl CargoRegistryService { "owners" => Self::handle_add_owners_request(path, &request), _ => Self::error_response(), }, - &Method::GET => match endpoint { + Method::GET => match endpoint { "crates" => Self::handle_get_crates_request(path, &request), "owners" => Self::handle_get_owners_request(path, &request), _ => Self::error_response(), }, - &Method::DELETE => match endpoint { + Method::DELETE => match endpoint { "yank" => Self::handle_yank_request(path, &request), "owners" => Self::handle_delete_owners_request(path, &request), _ => Self::error_response(), diff --git a/cargo-registry/src/publisher.rs b/cargo-registry/src/publisher.rs index 9086a014d2d73d..61dca5aadeff18 100644 --- a/cargo-registry/src/publisher.rs +++ b/cargo-registry/src/publisher.rs @@ -73,7 +73,7 @@ impl PackageMetaData { let (json_length, sizeof_length) = Self::read_u32_length(bytes)?; let end_of_meta_data = sizeof_length.saturating_add(json_length as usize); let json_body = bytes.slice(sizeof_length..end_of_meta_data); - from_slice::(&json_body.deref()).map(|data| (data, end_of_meta_data)) + from_slice::(json_body.deref()).map(|data| (data, end_of_meta_data)) } fn read_u32_length(bytes: &Bytes) -> serde_json::Result<(u32, usize)> {