Skip to content

Commit 39d9cd6

Browse files
committed
rust: xarray: Add xarray::remove() convenience function
Ensures the xarray is unlocked before the removed element is dropped.
1 parent a16486d commit 39d9cd6

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

rust/kernel/xarray.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@ impl<T: ForeignOwnable> XArray<T> {
197197
_not_send: NotThreadSafe,
198198
}
199199
}
200+
201+
/// Removes and returns the element at the given index.
202+
pub fn remove(&self, index: usize) -> Option<T> {
203+
let mut guard = self.lock();
204+
guard.remove(index)
205+
}
200206
}
201207

202208
/// A lock guard.

0 commit comments

Comments
 (0)