File tree Expand file tree Collapse file tree
vortex-array/src/arrays/primitive Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -596,6 +596,9 @@ impl PrimitiveData {
596596 }
597597
598598 /// Try to extract a mutable buffer from the PrimitiveData with zero copy.
599+ ///
600+ /// # Panic
601+ /// If the buffer is not of type T this will panic
599602 pub fn try_into_buffer_mut < T : NativePType > ( self ) -> Result < BufferMut < T > , Buffer < T > > {
600603 if T :: PTYPE != self . ptype ( ) {
601604 vortex_panic ! (
Original file line number Diff line number Diff line change @@ -136,11 +136,9 @@ where
136136
137137 // If F and T have the same byte width, try to take unique ownership of the buffer.
138138 let same_bit_width = F :: PTYPE . byte_width ( ) == T :: PTYPE . byte_width ( ) ;
139- let owned: Option < BufferMut < F > > = if same_bit_width {
140- array. into_owned ( ) . try_into_buffer_mut :: < F > ( ) . ok ( )
141- } else {
142- None
143- } ;
139+ let owned: Option < BufferMut < F > > = same_bit_width
140+ . then ( || array. into_owned ( ) . try_into_buffer_mut :: < F > ( ) . ok ( ) )
141+ . flatten ( ) ;
144142 let values: & [ F ] = array. as_slice :: < F > ( ) ;
145143
146144 if infallible {
You can’t perform that action at this time.
0 commit comments