Avoid temporary variable `fin`

pull/143/head
philipp 4 years ago
parent 31e087f325
commit 599b677f5a
  1. 8
      src/protocol/message.rs

@ -37,20 +37,16 @@ mod string_collect {
let mut input: &[u8] = tail.as_ref(); let mut input: &[u8] = tail.as_ref();
if let Some(mut incomplete) = self.incomplete.take() { if let Some(mut incomplete) = self.incomplete.take() {
let fin = if let Some((result, rest)) = incomplete.try_complete(input) { if let Some((result, rest)) = incomplete.try_complete(input) {
input = rest; input = rest;
if let Ok(text) = result { if let Ok(text) = result {
self.data.push_str(text); self.data.push_str(text);
} else { } else {
return Err(Error::Utf8); return Err(Error::Utf8);
} }
true
} else { } else {
input = &[]; input = &[];
false self.incomplete = Some(incomplete);
};
if !fin {
self.incomplete = Some(incomplete)
} }
} }

Loading…
Cancel
Save