From 2ff8b2a7068ad5fd08e1e0f44cc132481463c874 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Thu, 4 Nov 2021 10:17:15 +0000 Subject: [PATCH] Update lines.rs --- actix-codec/src/lines.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/actix-codec/src/lines.rs b/actix-codec/src/lines.rs index 387245ff..af399e8f 100644 --- a/actix-codec/src/lines.rs +++ b/actix-codec/src/lines.rs @@ -67,11 +67,9 @@ impl Decoder for LinesCodec { Some(frame) => Ok(Some(frame)), None if src.is_empty() => Ok(None), None => { - let len = src.len(); - let buf = match src.last() { // if last line ends in a CR then take everything up to it - Some(b'\r') => src.split_to(len - 1), + Some(b'\r') => src.split_to(src.len() - 1), // take all bytes from source _ => src.split(), @@ -81,7 +79,7 @@ impl Decoder for LinesCodec { return Ok(None); } - return try_into_utf8(buf.freeze()); + try_into_utf8(buf.freeze()) } } }