summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2025-03-27 22:03:21 +0100
committerHampusM <hampus@hampusmat.com>2025-03-28 11:53:10 +0100
commite71c96e85eeb1878909bb081b3f418ed266ace93 (patch)
tree24c292302d29c1f29b940ef043ca9b3c9472dee4
parent8fe9532383cbcf4b68dd4273ec35919fe589fa73 (diff)
feat: add get_item_mut fn to FieldSliceMut
-rw-r--r--src/lib.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 12689c7..1d52d91 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -501,6 +501,24 @@ pub struct FieldSliceMut<'mv>
impl FieldSliceMut<'_>
{
+ pub fn get_item_mut(&mut self, item_index: usize) -> Option<FieldMut<'_>>
+ {
+ let start_off = item_index * self.field_metadata.size;
+
+ if item_index >= self.len {
+ return None;
+ }
+
+ let field_bytes = self
+ .bytes
+ .get_mut(start_off..start_off + self.field_metadata.size)?;
+
+ Some(FieldMut {
+ bytes: field_bytes,
+ field_metadata: self.field_metadata,
+ })
+ }
+
pub fn iter_mut(&mut self) -> FieldSliceIterMut<'_>
{
FieldSliceIterMut {