Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Improved example (#1131)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecarleitao committed Jun 30, 2022
1 parent 9b095ea commit c52b3e7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions examples/cow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,20 @@ fn main() {

// confirm that it gives the right result :)
assert_eq!(array, &PrimitiveArray::from_vec(vec![10i32, 20]));

// alternatively, you can use `get_mut_values`. Unwrap works because it is single owned
let values = array.get_mut_values().unwrap();
values[0] = 0;

assert_eq!(array, &PrimitiveArray::from_vec(vec![0, 20]));

// you can also modify the validity:
array.set_validity(Some([true, false].into()));
array.apply_validity(|bitmap| {
let mut mut_bitmap = bitmap.into_mut().right().unwrap();
mut_bitmap.set(1, true);
mut_bitmap.into()
});

assert_eq!(array, &PrimitiveArray::from_vec(vec![0, 20]));
}

0 comments on commit c52b3e7

Please sign in to comment.