Skip to content

Commit

Permalink
chore: Fix clippy warning
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto committed Sep 8, 2023
1 parent d59fe0d commit ca6ce3e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 18 deletions.
12 changes: 6 additions & 6 deletions codegen/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::path::PathBuf;
use std::path::{Path, PathBuf};

fn main() {
// tonic-health
Expand Down Expand Up @@ -45,11 +45,11 @@ fn main() {
}

fn codegen(
root_dir: &PathBuf,
root_dir: &Path,
iface_files: &[&str],
include_dirs: &[&str],
out_dir: &PathBuf,
file_descriptor_set_path: &PathBuf,
out_dir: &Path,
file_descriptor_set_path: &Path,
build_client: bool,
build_server: bool,
) {
Expand All @@ -59,12 +59,12 @@ fn codegen(
.unwrap();

let iface_files: Vec<PathBuf> = iface_files
.into_iter()
.iter()
.map(|&path| root_dir.join(path))
.collect();

let include_dirs: Vec<PathBuf> = include_dirs
.into_iter()
.iter()
.map(|&path| root_dir.join(path))
.collect();
let out_dir = root_dir.join(out_dir);
Expand Down
10 changes: 2 additions & 8 deletions examples/src/dynamic/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ impl Echo for MyEcho {
}

fn init_echo(args: &[String], builder: &mut RoutesBuilder) {
let enabled = args
.into_iter()
.find(|arg| arg.as_str() == "echo")
.is_some();
let enabled = args.iter().any(|arg| arg.as_str() == "echo");
if enabled {
println!("Adding Echo service...");
let svc = EchoServer::new(MyEcho::default());
Expand All @@ -62,10 +59,7 @@ impl Greeter for MyGreeter {
}

fn init_greeter(args: &[String], builder: &mut RoutesBuilder) {
let enabled = args
.into_iter()
.find(|arg| arg.as_str() == "greeter")
.is_some();
let enabled = args.iter().any(|arg| arg.as_str() == "greeter");

if enabled {
println!("Adding Greeter service...");
Expand Down
2 changes: 2 additions & 0 deletions tonic-build/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use proc_macro2::{Span, TokenStream};
use quote::quote;
use syn::{Ident, Lit, LitStr};

#[allow(clippy::too_many_arguments)]
pub(crate) fn generate_internal<T: Service>(
service: &T,
emit_package: bool,
Expand Down Expand Up @@ -209,6 +210,7 @@ pub(crate) fn generate_internal<T: Service>(
}
}

#[allow(clippy::too_many_arguments)]
fn generate_trait<T: Service>(
service: &T,
emit_package: bool,
Expand Down
4 changes: 2 additions & 2 deletions tonic-web/src/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ fn make_trailers_frame(trailers: HeaderMap) -> Vec<u8> {
/// or the buffer jsut contained grpc message frames.
fn find_trailers(buf: &[u8]) -> Option<usize> {
let mut len = 0;
let mut temp_buf = &buf[..];
let mut temp_buf = buf;

loop {
// To check each frame, there must be at least GRPC_HEADER_SIZE
Expand All @@ -440,7 +440,7 @@ fn find_trailers(buf: &[u8]) -> Option<usize> {
return None;
}

temp_buf = &buf[len as usize..];
temp_buf = &buf[len..];
}
}

Expand Down
4 changes: 2 additions & 2 deletions tonic/src/codec/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ where
BytesMut::new()
};

return EncodedBytes {
Self {
source: Fuse::new(source),
encoder,
compression_encoding,
max_message_size,
buf,
uncompression_buf,
};
}
}
}

Expand Down

0 comments on commit ca6ce3e

Please sign in to comment.