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

Improved example #1131

Merged
merged 1 commit into from
Jun 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]));
}