From 9498c45d1291c0b2343339bad624d0dc0ca0a934 Mon Sep 17 00:00:00 2001 From: Lizzy Fleckenstein Date: Wed, 15 Feb 2023 22:04:42 +0100 Subject: Use Cow for Pkt --- src/recv.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/recv.rs') diff --git a/src/recv.rs b/src/recv.rs index 572b17e..c87a0fe 100644 --- a/src/recv.rs +++ b/src/recv.rs @@ -2,6 +2,7 @@ use super::*; use async_recursion::async_recursion; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use std::{ + borrow::Cow, cell::OnceCell, collections::HashMap, io, @@ -114,7 +115,7 @@ impl RecvWorker { Pkt { unrel: true, chan: 0, - data: &[CtlType::Disco as u8], + data: Cow::Borrowed(&[CtlType::Disco as u8]), }, ) .await @@ -210,7 +211,7 @@ impl RecvWorker { self.pkt_tx.send(Ok(Pkt { chan: chan.num, unrel, - data: cursor.remaining_slice().into(), + data: Cow::Owned(cursor.remaining_slice().into()), }))?; } PktType::Split => { @@ -273,7 +274,7 @@ impl RecvWorker { Pkt { unrel: true, chan: chan.num, - data: &ack_data, + data: Cow::Borrowed(&ack_data), }, ) .await?; -- cgit v1.2.3