File tree Expand file tree Collapse file tree 4 files changed +28
-2
lines changed Expand file tree Collapse file tree 4 files changed +28
-2
lines changed Original file line number Diff line number Diff line change 11[package ]
22name = " minarrow"
3- version = " 0.2.0 "
3+ version = " 0.2.1 "
44edition = " 2024"
55authors = [' Peter G. Bower' ]
66build = " build.rs"
Original file line number Diff line number Diff line change @@ -170,6 +170,17 @@ impl Bitmask {
170170 !self . all_set ( )
171171 }
172172
173+ /// Creates an owned copy of the bitmask.
174+ /// Always creates a fresh owned copy, even if already owned.
175+ #[ inline]
176+ pub fn to_owned_copy ( & self ) -> Self {
177+ let owned_bits = self . bits . to_owned_copy ( ) ;
178+ Bitmask {
179+ bits : owned_bits,
180+ len : self . len ,
181+ }
182+ }
183+
173184 /// Returns bit *idx*.
174185 /// - If `idx ≥ self.len` but still inside the physical buffer, returns `false`.
175186 /// Panics only when `idx` exceeds the physical capacity.
@@ -720,6 +731,7 @@ impl Display for Bitmask {
720731 }
721732}
722733
734+
723735#[ cfg( test) ]
724736mod tests {
725737 use super :: * ;
Original file line number Diff line number Diff line change @@ -358,6 +358,19 @@ impl<T> Buffer<T> {
358358 pub fn is_shared ( & self ) -> bool {
359359 matches ! ( self . storage, Storage :: Shared { .. } )
360360 }
361+
362+ /// Creates an owned copy of the buffer data.
363+ /// If the buffer is already owned, this clones the data.
364+ /// If the buffer is shared, this copies the data into a new owned Vec64.
365+ #[ inline]
366+ pub fn to_owned_copy ( & self ) -> Self
367+ where
368+ T : Clone ,
369+ {
370+ // Always create a fresh owned copy
371+ let vec: Vec64 < T > = self . as_ref ( ) . iter ( ) . cloned ( ) . collect ( ) ;
372+ Buffer :: from_vec64 ( vec)
373+ }
361374}
362375
363376impl < T : Clone > Buffer < T > {
@@ -593,6 +606,7 @@ impl<T: Display> Display for Buffer<T> {
593606 }
594607}
595608
609+
596610// SAFETY: Shared buffers are read-only and `Arc` ensures memory is valid.
597611// `Owned` is already `Send + Sync` via `Vec64<T>`.
598612unsafe impl < T : Sync > Sync for Buffer < T > { }
You can’t perform that action at this time.
0 commit comments