From ccc2ddab6694a0588d191aec5ab3fa2c82c60b18 Mon Sep 17 00:00:00 2001 From: Mathias <mk@blackbird.online> Date: Thu, 18 Jul 2024 12:14:56 +0200 Subject: [PATCH] Hand-roll Clone impl instead of derive --- embassy-embedded-hal/src/flash/partition/asynch.rs | 11 ++++++++++- embassy-embedded-hal/src/flash/partition/blocking.rs | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/embassy-embedded-hal/src/flash/partition/asynch.rs b/embassy-embedded-hal/src/flash/partition/asynch.rs index 576e7e5b6..1b0c91232 100644 --- a/embassy-embedded-hal/src/flash/partition/asynch.rs +++ b/embassy-embedded-hal/src/flash/partition/asynch.rs @@ -12,13 +12,22 @@ use super::Error; /// There is no guarantee that muliple partitions on the same flash /// operate on mutually exclusive ranges - such a separation is up to /// the user to guarantee. -#[derive(Clone)] pub struct Partition<'a, M: RawMutex, T: NorFlash> { flash: &'a Mutex<M, T>, offset: u32, size: u32, } +impl<'a, M: RawMutex, T: NorFlash> Clone for Partition<'a, M, T> { + fn clone(&self) -> Self { + Self { + flash: self.flash, + offset: self.offset, + size: self.size, + } + } +} + impl<'a, M: RawMutex, T: NorFlash> Partition<'a, M, T> { /// Create a new partition pub const fn new(flash: &'a Mutex<M, T>, offset: u32, size: u32) -> Self { diff --git a/embassy-embedded-hal/src/flash/partition/blocking.rs b/embassy-embedded-hal/src/flash/partition/blocking.rs index 478f39246..a68df7812 100644 --- a/embassy-embedded-hal/src/flash/partition/blocking.rs +++ b/embassy-embedded-hal/src/flash/partition/blocking.rs @@ -13,13 +13,22 @@ use super::Error; /// There is no guarantee that muliple partitions on the same flash /// operate on mutually exclusive ranges - such a separation is up to /// the user to guarantee. -#[derive(Clone)] pub struct BlockingPartition<'a, M: RawMutex, T: NorFlash> { flash: &'a Mutex<M, RefCell<T>>, offset: u32, size: u32, } +impl<'a, M: RawMutex, T: NorFlash> Clone for BlockingPartition<'a, M, T> { + fn clone(&self) -> Self { + Self { + flash: self.flash, + offset: self.offset, + size: self.size, + } + } +} + impl<'a, M: RawMutex, T: NorFlash> BlockingPartition<'a, M, T> { /// Create a new partition pub const fn new(flash: &'a Mutex<M, RefCell<T>>, offset: u32, size: u32) -> Self {