From 783e43739742cf3b3dc2f450ca887136bb29b706 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Sun, 28 Jun 2020 18:39:57 -0700 Subject: [PATCH] protocol: fix manually copying, use clone_from_slice, thanks clippy! (manual_memcpy) --- protocol/src/protocol/mod.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/protocol/src/protocol/mod.rs b/protocol/src/protocol/mod.rs index b6db693..241d9b5 100644 --- a/protocol/src/protocol/mod.rs +++ b/protocol/src/protocol/mod.rs @@ -1343,11 +1343,8 @@ impl Write for Conn { match self.cipher.as_mut() { Option::None => self.stream.write(buf), Option::Some(cipher) => { - // TODO: avoid copying, but trait requires non-mutable buf let mut data = vec![0; buf.len()]; - for i in 0..buf.len() { - data[i] = buf[i]; - } + data[..buf.len()].clone_from_slice(&buf[..]); cipher.encrypt(&mut data);