diff --git a/benches/read.rs b/benches/read.rs index 82e66a51..9f6f24f4 100644 --- a/benches/read.rs +++ b/benches/read.rs @@ -51,7 +51,10 @@ fn benchmark(c: &mut Criterion) { for i in 0_u64..100_000 { writer .send(match i { - _ if i % 3 == 0 => Message::Binary(i.to_le_bytes().into()), + _ if i % 3 == 0 => { + let data: Vec = i.to_le_bytes().into(); + Message::Binary(data.into()) + } _ => Message::Text(format!("{{\"id\":{i}}}")), }) .unwrap(); diff --git a/benches/write.rs b/benches/write.rs index 02bad6ac..2e23b87d 100644 --- a/benches/write.rs +++ b/benches/write.rs @@ -57,7 +57,10 @@ fn benchmark(c: &mut Criterion) { b.iter(|| { for i in 0_u64..100_000 { let msg = match i { - _ if i % 3 == 0 => Message::Binary(i.to_le_bytes().into()), + _ if i % 3 == 0 => { + let data: Vec = i.to_le_bytes().into(); + Message::Binary(data.into()) + } _ => Message::Text(format!("{{\"id\":{i}}}")), }; ws.write(msg).unwrap(); diff --git a/src/protocol/message.rs b/src/protocol/message.rs index ac9b220d..502906ba 100644 --- a/src/protocol/message.rs +++ b/src/protocol/message.rs @@ -284,7 +284,8 @@ impl<'s> From<&'s str> for Message { impl<'b> From<&'b [u8]> for Message { fn from(data: &'b [u8]) -> Self { - Message::binary(data.to_vec()) + let data: Vec = data.into(); + Message::binary(data) } }