chore: Apply clippy (#189)
This commit is contained in:
@@ -21,7 +21,7 @@ impl Greeter for MyGreeter {
|
||||
println!("Got a request from {:?}", request.remote_addr());
|
||||
|
||||
let reply = hello_world::HelloReply {
|
||||
message: format!("Hello {}!", request.into_inner().name).into(),
|
||||
message: format!("Hello {}!", request.into_inner().name),
|
||||
};
|
||||
Ok(Response::new(reply))
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ use tonic::transport::Channel;
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let endpoints = ["http://[::1]:50051", "http://[::1]:50052"]
|
||||
.into_iter()
|
||||
.iter()
|
||||
.map(|a| Channel::from_static(a));
|
||||
|
||||
let channel = Channel::balance_list(endpoints);
|
||||
|
||||
@@ -48,7 +48,7 @@ impl Greeter for MyGreeter {
|
||||
request: Request<HelloRequest>,
|
||||
) -> Result<Response<HelloReply>, Status> {
|
||||
let reply = hello_world::HelloReply {
|
||||
message: format!("Hello {}!", request.into_inner().name).into(),
|
||||
message: format!("Hello {}!", request.into_inner().name),
|
||||
};
|
||||
Ok(Response::new(reply))
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@ use route_guide::routeguide_client::RouteGuideClient;
|
||||
async fn print_features(client: &mut RouteGuideClient<Channel>) -> Result<(), Box<dyn Error>> {
|
||||
let rectangle = Rectangle {
|
||||
lo: Some(Point {
|
||||
latitude: 400000000,
|
||||
longitude: -750000000,
|
||||
latitude: 400_000_000,
|
||||
longitude: -750_000_000,
|
||||
}),
|
||||
hi: Some(Point {
|
||||
latitude: 420000000,
|
||||
longitude: -730000000,
|
||||
latitude: 420_000_000,
|
||||
longitude: -730_000_000,
|
||||
}),
|
||||
};
|
||||
|
||||
@@ -96,8 +96,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
println!("*** SIMPLE RPC ***");
|
||||
let response = client
|
||||
.get_feature(Request::new(Point {
|
||||
latitude: 409146138,
|
||||
longitude: -746188906,
|
||||
latitude: 409_146_138,
|
||||
longitude: -746_188_906,
|
||||
}))
|
||||
.await?;
|
||||
println!("RESPONSE = {:?}", response);
|
||||
|
||||
@@ -195,7 +195,7 @@ fn in_range(point: &Point, rect: &Rectangle) -> bool {
|
||||
/// This code was taken from http://www.movable-type.co.uk/scripts/latlong.html.
|
||||
fn calc_distance(p1: &Point, p2: &Point) -> i32 {
|
||||
const CORD_FACTOR: f64 = 1e7;
|
||||
const R: f64 = 6371000.0; // meters
|
||||
const R: f64 = 6_371_000.0; // meters
|
||||
|
||||
let lat1 = p1.latitude as f64 / CORD_FACTOR;
|
||||
let lat2 = p2.latitude as f64 / CORD_FACTOR;
|
||||
|
||||
@@ -21,7 +21,7 @@ impl Greeter for MyGreeter {
|
||||
tracing::info!(message = "Inbound request.", metadata = ?request.metadata());
|
||||
|
||||
let reply = hello_world::HelloReply {
|
||||
message: format!("Hello {}!", request.into_inner().name).into(),
|
||||
message: format!("Hello {}!", request.into_inner().name),
|
||||
};
|
||||
|
||||
tracing::debug!(message = "Sending reply.", response = %reply.message);
|
||||
|
||||
@@ -34,7 +34,7 @@ impl Greeter for MyGreeter {
|
||||
println!("Got a request: {:?}", request);
|
||||
|
||||
let reply = hello_world::HelloReply {
|
||||
message: format!("Hello {}!", request.into_inner().name).into(),
|
||||
message: format!("Hello {}!", request.into_inner().name),
|
||||
};
|
||||
Ok(Response::new(reply))
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@ use tonic::{metadata::MetadataValue, Code, Request, Response, Status};
|
||||
pub type TestClient = TestServiceClient<Channel>;
|
||||
pub type UnimplementedClient = UnimplementedServiceClient<Channel>;
|
||||
|
||||
const LARGE_REQ_SIZE: usize = 271828;
|
||||
const LARGE_RSP_SIZE: i32 = 314159;
|
||||
const REQUEST_LENGTHS: &'static [i32] = &[27182, 8, 1828, 45904];
|
||||
const RESPONSE_LENGTHS: &'static [i32] = &[31415, 9, 2653, 58979];
|
||||
const TEST_STATUS_MESSAGE: &'static str = "test status message";
|
||||
const SPECIAL_TEST_STATUS_MESSAGE: &'static str =
|
||||
const LARGE_REQ_SIZE: usize = 271_828;
|
||||
const LARGE_RSP_SIZE: i32 = 314_159;
|
||||
const REQUEST_LENGTHS: &[i32] = &[27182, 8, 1828, 45904];
|
||||
const RESPONSE_LENGTHS: &[i32] = &[31415, 9, 2653, 58979];
|
||||
const TEST_STATUS_MESSAGE: &str = "test status message";
|
||||
const SPECIAL_TEST_STATUS_MESSAGE: &str =
|
||||
"\t\ntest with whitespace\r\nand Unicode BMP ☺ and non-BMP 😈\t\n";
|
||||
|
||||
pub async fn empty_unary(client: &mut TestClient, assertions: &mut Vec<TestAssertion>) {
|
||||
@@ -217,7 +217,7 @@ pub async fn empty_stream(client: &mut TestClient, assertions: &mut Vec<TestAsse
|
||||
|
||||
assertions.push(test_assert!(
|
||||
"there should be no responses",
|
||||
responses.len() == 0,
|
||||
responses.is_empty(),
|
||||
format!("responses.len()={:?}", responses.len())
|
||||
));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user