Skip to content

Commit 2d3102e

Browse files
committed
Remove use of unsafe
This no longer needs to be unsafe. This is likely because `Packet` no longer borrows from PacketConn.bytes.
1 parent f5c4e84 commit 2d3102e

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

src/packet.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,7 @@ impl<R: Read + Write> PacketConn<R> {
9595

9696
loop {
9797
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) {
98+
match packet(&self.bytes[self.start..]) {
10799
Ok((rest, p)) => {
108100
self.remaining = rest.len();
109101
return Ok(Some(p));

0 commit comments

Comments
 (0)