From d25c17fa7b3e374e49fd69f90cd424cf258f8d6f Mon Sep 17 00:00:00 2001 From: Joe Prosser Date: Thu, 25 Jul 2024 18:20:31 +0100 Subject: [PATCH] dont clone when splitting --- api/src/lib.rs | 2 +- api/src/resources/comment.rs | 10 ++++------ api/src/resources/email.rs | 5 ++--- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/api/src/lib.rs b/api/src/lib.rs index c7cc470..095a277 100644 --- a/api/src/lib.rs +++ b/api/src/lib.rs @@ -144,7 +144,7 @@ pub use crate::{ pub struct Token(pub String); pub trait SplittableRequest { - fn split(&self) -> Vec + fn split(self) -> Vec where Self: Sized; diff --git a/api/src/resources/comment.rs b/api/src/resources/comment.rs index d0c1fba..cb4638b 100644 --- a/api/src/resources/comment.rs +++ b/api/src/resources/comment.rs @@ -175,12 +175,11 @@ pub(crate) struct PutCommentsRequest { } impl SplittableRequest for PutCommentsRequest { - fn split(&self) -> Vec { + fn split(self) -> Vec { self.comments - .clone() .into_iter() .map(|comment| Self { - comments: [comment].to_vec(), + comments: vec![comment], }) .collect() } @@ -208,15 +207,14 @@ pub(crate) struct SyncCommentsRequest { } impl SplittableRequest for SyncCommentsRequest { - fn split(&self) -> Vec + fn split(self) -> Vec where Self: Sized, { self.comments - .clone() .into_iter() .map(|comment| Self { - comments: [comment].to_vec(), + comments: vec![comment], }) .collect() } diff --git a/api/src/resources/email.rs b/api/src/resources/email.rs index 734b70f..a972574 100644 --- a/api/src/resources/email.rs +++ b/api/src/resources/email.rs @@ -56,15 +56,14 @@ pub(crate) struct PutEmailsRequest { } impl SplittableRequest for PutEmailsRequest { - fn split(&self) -> Vec + fn split(self) -> Vec where Self: Sized, { self.emails - .clone() .into_iter() .map(|email| Self { - emails: [email].to_vec(), + emails: vec![email], }) .collect() }