Skip to content

Commit f6cf722

Browse files
authored
turn: simplify result_ch_rx (#691)
Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
1 parent e7392d2 commit f6cf722

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

turn/src/client/mod.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,12 @@ impl RelayConnObserver for ClientInternal {
150150
}
151151

152152
// wait_for_result waits for the transaction result
153-
if let Some(mut result_ch_rx) = result_ch_rx {
154-
match result_ch_rx.recv().await {
155-
Some(tr) => Ok(tr),
156-
None => Err(Error::ErrTransactionClosed),
157-
}
158-
} else {
159-
Err(Error::ErrWaitForResultOnNonResultTransaction)
160-
}
153+
let mut result_ch_rx = result_ch_rx.ok_or(Error::ErrWaitForResultOnNonResultTransaction)?;
154+
let tr = result_ch_rx
155+
.recv()
156+
.await
157+
.ok_or(Error::ErrTransactionClosed)?;
158+
Ok(tr)
161159
}
162160
}
163161

0 commit comments

Comments
 (0)