diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e3f0f1..3443bc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ ## Unreleased +### Breaking changes + +- Take `self` rather than `&mut self` for `UniqueMmioPointer::split`. The old behaviour can be + achieved by calling `reborrow` first. +- Take `self` rather than `&self` for `SharedMmioPointer::split`. `SharedMmioPointer` is `Copy` so + this should make no difference in most cases. + ### Improvements - Added `modify` and `modify_mut` methods to `UniqueMmioPointer>` and diff --git a/src/lib.rs b/src/lib.rs index 02f7bef..e37335c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -334,7 +334,7 @@ impl<'a, T> UniqueMmioPointer<'a, [T]> { impl<'a, T, const LEN: usize> UniqueMmioPointer<'a, [T; LEN]> { /// Splits a `UniqueMmioPointer` to an array into an array of `UniqueMmioPointer`s. - pub fn split(&mut self) -> [UniqueMmioPointer<'_, T>; LEN] { + pub fn split(mut self) -> [UniqueMmioPointer<'a, T>; LEN] { array::from_fn(|i| { UniqueMmioPointer(SharedMmioPointer { // SAFETY: self.regs is always unique and valid for MMIO access. We make sure the @@ -787,7 +787,7 @@ impl<'a, T> SharedMmioPointer<'a, [T]> { impl<'a, T, const LEN: usize> SharedMmioPointer<'a, [T; LEN]> { /// Splits a `SharedMmioPointer` to an array into an array of `SharedMmioPointer`s. - pub fn split(&self) -> [SharedMmioPointer<'a, T>; LEN] { + pub fn split(self) -> [SharedMmioPointer<'a, T>; LEN] { array::from_fn(|i| SharedMmioPointer { // SAFETY: self.regs is always unique and valid for MMIO access. We make sure the // pointers we split it into don't overlap, so the same applies to each of them. @@ -1126,7 +1126,7 @@ mod tests { let mut foo = [ReadWrite(1), ReadWrite(2), ReadWrite(3)]; let mut owned = UniqueMmioPointer::from(&mut foo); - let mut parts = owned.split(); + let mut parts = owned.reborrow().split(); assert_eq!(parts[0].read(), 1); assert_eq!(parts[1].read(), 2); assert_eq!(owned.split()[2].read(), 3);