Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<ReadWrite<T>>` and
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down