diff options
| author | acdenisSK <[email protected]> | 2017-07-20 18:34:55 +0200 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2017-07-20 18:34:55 +0200 |
| commit | f5a97d43b467130fd97af8c8a0dd1bbf0e7f5326 (patch) | |
| tree | 1736d559f602bd2dcb094b94da2b7b7732c7a8c2 /src/voice/connection.rs | |
| parent | Add an actual way to fetch audit log entries from a guild (diff) | |
| download | serenity-f5a97d43b467130fd97af8c8a0dd1bbf0e7f5326.tar.xz serenity-f5a97d43b467130fd97af8c8a0dd1bbf0e7f5326.zip | |
Utilise the newly stabilised loop-with-break-value
Diffstat (limited to 'src/voice/connection.rs')
| -rw-r--r-- | src/voice/connection.rs | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/src/voice/connection.rs b/src/voice/connection.rs index 801c871..ced6a79 100644 --- a/src/voice/connection.rs +++ b/src/voice/connection.rs @@ -71,27 +71,19 @@ impl Connection { client.send_json(&payload::build_identify(&info))?; - let hello = { - let hello; - - loop { - match client.recv_json(VoiceEvent::decode)? { - VoiceEvent::Hello(received_hello) => { - hello = received_hello; - - break; - }, - VoiceEvent::Heartbeat(_) => continue, - other => { - debug!("[Voice] Expected hello/heartbeat; got: {:?}", - other); - - return Err(Error::Voice(VoiceError::ExpectedHandshake)); - }, - } + let hello = loop { + match client.recv_json(VoiceEvent::decode)? { + VoiceEvent::Hello(received_hello) => { + break received_hello; + }, + VoiceEvent::Heartbeat(_) => continue, + other => { + debug!("[Voice] Expected hello/heartbeat; got: {:?}", + other); + + return Err(Error::Voice(VoiceError::ExpectedHandshake)); + }, } - - hello }; if !has_valid_mode(&hello.modes) { |