Skip to content

Commit

Permalink
chore: Use let-else statement (#1776)
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto authored Jul 6, 2024
1 parent f8e1f87 commit 1c327a2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
7 changes: 2 additions & 5 deletions tonic-reflection/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,8 @@ impl ServerReflection for ReflectionService {

tokio::spawn(async move {
while let Some(req) = req_rx.next().await {
let req = match req {
Ok(req) => req,
Err(_) => {
return;
}
let Ok(req) = req else {
return;
};

let resp_msg = match req.message_request.clone() {
Expand Down
4 changes: 1 addition & 3 deletions tonic/src/codec/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,7 @@ impl CompressionEncoding {
map: &http::HeaderMap,
enabled_encodings: EnabledCompressionEncodings,
) -> Result<Option<Self>, Status> {
let header_value = if let Some(value) = map.get(ENCODING_HEADER) {
value
} else {
let Some(header_value) = map.get(ENCODING_HEADER) else {
return Ok(None);
};

Expand Down
5 changes: 2 additions & 3 deletions tonic/src/transport/channel/service/reconnect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,8 @@ where
return ResponseFuture::error(error);
}

let service = match self.state {
State::Connected(ref mut service) => service,
_ => panic!("service not ready; poll_ready must be called first"),
let State::Connected(service) = &mut self.state else {
panic!("service not ready; poll_ready must be called first");
};

let fut = service.call(request);
Expand Down

0 comments on commit 1c327a2

Please sign in to comment.