MCPcopy Create free account
hub / github.com/apache/arrow-rs / bitwise_unary_mut_or_clone

Method bitwise_unary_mut_or_clone

arrow-array/src/array/boolean_array.rs:388–396  ·  view source on GitHub ↗

Apply a bitwise operation to this array's values in place if the buffer is uniquely owned, or clone and apply if shared. This is a convenience wrapper around [`bitwise_unary_mut`](Self::bitwise_unary_mut) that falls back to [`bitwise_unary`](Self::bitwise_unary) when the buffer is shared. The null buffer is preserved unchanged. # Example ``` # use arrow_array::BooleanArray; let array = Boolean

(self, op: F)

Source from the content-addressed store, hash-verified

386 /// assert_eq!(result, BooleanArray::from(vec![false, true, false]));
387 /// ```
388 pub fn bitwise_unary_mut_or_clone<F>(self, op: F) -> BooleanArray
389 where
390 F: FnMut(u64) -> u64,
391 {
392 match self.try_bitwise_unary_in_place(op) {
393 Ok(array) => array,
394 Err((array, op)) => array.bitwise_unary(op),
395 }
396 }
397
398 /// Try to apply a unary op in place. Returns `op` back on failure so
399 /// callers can fall back to an allocating path without requiring `F: Clone`.

Calls 2

bitwise_unaryMethod · 0.80