Skip to content

Commit 15f93ab

Browse files
committed
1 parent 9d3f9da commit 15f93ab

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/sync/client.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -225,19 +225,16 @@ impl Client {
225225
.send((buf, tx))
226226
.map_err(err_to_others_err!(e, "Send packet to sender error "))?;
227227

228-
let result: Result<Vec<u8>>;
229-
if req.timeout_nano == 0 {
230-
result = rx
231-
.recv()
232-
.map_err(err_to_others_err!(e, "Receive packet from recver error: "))?;
228+
let result = if req.timeout_nano == 0 {
229+
rx.recv()
230+
.map_err(err_to_others_err!(e, "Receive packet from recver error: "))?
233231
} else {
234-
result = rx
235-
.recv_timeout(Duration::from_nanos(req.timeout_nano as u64))
232+
rx.recv_timeout(Duration::from_nanos(req.timeout_nano as u64))
236233
.map_err(err_to_others_err!(
237234
e,
238235
"Receive packet from recver timeout: "
239-
))?;
240-
}
236+
))?
237+
};
241238

242239
let buf = result?;
243240
let mut s = CodedInputStream::from_bytes(&buf);

src/sync/server.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,8 @@ fn start_method_handler_thread(
188188
trace!("Got Message request {:?}", req);
189189

190190
let path = format!("/{}/{}", req.service, req.method);
191-
let method;
192-
if let Some(x) = methods.get(&path) {
193-
method = x;
191+
let method = if let Some(x) = methods.get(&path) {
192+
x
194193
} else {
195194
let status = get_status(Code::INVALID_ARGUMENT, format!("{} does not exist", path));
196195
let mut res = Response::new();
@@ -207,7 +206,7 @@ fn start_method_handler_thread(
207206
break;
208207
}
209208
continue;
210-
}
209+
};
211210
let ctx = TtrpcContext {
212211
fd,
213212
mh,

0 commit comments

Comments
 (0)