We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 6fe6041 + 2d3102e commit b8f754aCopy full SHA for b8f754a
src/packet.rs
@@ -95,15 +95,7 @@ impl<R: Read + Write> PacketConn<R> {
95
96
loop {
97
if self.remaining != 0 {
98
- let bytes = {
99
- // NOTE: this is all sorts of unfortunate. what we really want to do is to give
100
- // &self.bytes[self.start..] to `packet()`, and the lifetimes should all work
101
- // out. however, without NLL, borrowck doesn't realize that self.bytes is no
102
- // longer borrowed after the match, and so can be mutated.
103
- let bytes = &self.bytes[self.start..];
104
- unsafe { ::std::slice::from_raw_parts(bytes.as_ptr(), bytes.len()) }
105
- };
106
- match packet(bytes) {
+ match packet(&self.bytes[self.start..]) {
107
Ok((rest, p)) => {
108
self.remaining = rest.len();
109
return Ok(Some(p));
0 commit comments