From 3d5d80e6cca0b11705e99f5b69f798bd2f04eb4a Mon Sep 17 00:00:00 2001 From: Eivind Alexander Bergem Date: Fri, 23 Aug 2024 14:56:12 +0200 Subject: [PATCH] Queue shouldn't require `Copy` By requiring items to be `Copy` we reduce the queue to only work with primitives. But, queue dosn't require `Copy` to send items. Yes, they are technically copied over to the Queue buffer, but semantically this is a move, and having `send()` consume it's argument provides the move semantics. --- freertos-rust/src/queue.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/freertos-rust/src/queue.rs b/freertos-rust/src/queue.rs index a9071ff..1fe6fd4 100644 --- a/freertos-rust/src/queue.rs +++ b/freertos-rust/src/queue.rs @@ -4,18 +4,17 @@ use crate::prelude::v1::*; use crate::shim::*; use crate::units::*; -unsafe impl Send for Queue {} -unsafe impl Sync for Queue {} +unsafe impl Send for Queue {} +unsafe impl Sync for Queue {} -/// A queue with a finite size. The items are owned by the queue and are -/// copied. +/// A queue with a finite size. #[derive(Debug)] -pub struct Queue { +pub struct Queue { queue: FreeRtosQueueHandle, item_type: PhantomData, } -impl Queue { +impl Queue { pub fn new(max_size: usize) -> Result, FreeRtosError> { let item_size = mem::size_of::(); @@ -107,7 +106,7 @@ impl Queue { } } -impl Drop for Queue { +impl Drop for Queue { fn drop(&mut self) { unsafe { freertos_rs_queue_delete(self.queue);