Skip to content

Commit

Permalink
fix(rust): Fix inconsistency between code and comment (#19810)
Browse files Browse the repository at this point in the history
  • Loading branch information
YichiZhang0613 authored Nov 15, 2024
1 parent 9df0b79 commit 989eade
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/polars-arrow/src/array/primitive/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ impl<T: NativeType> MutablePrimitiveArray<T> {

/// Sets values.
/// # Panic
/// Panics iff the values' length is not equal to the existing validity's len.
/// Panics iff the values' length is not equal to the existing values' len.
pub fn set_values(&mut self, values: Vec<T>) {
assert_eq!(values.len(), self.values.len());
self.values = values;
Expand Down
2 changes: 1 addition & 1 deletion crates/polars-core/src/chunked_array/object/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ where

/// Sets the validity of this array.
/// # Panics
/// This function panics iff `values.len() != self.len()`.
/// This function panics iff `validity.len() != self.len()`.
#[inline]
pub fn set_validity(&mut self, validity: Option<Bitmap>) {
if matches!(&validity, Some(bitmap) if bitmap.len() != self.len()) {
Expand Down
1 change: 1 addition & 0 deletions crates/polars-parquet/src/parquet/encoding/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub use crate::parquet::parquet_bridge::Encoding;
/// This function panics iff `values.len() < 4`.
#[inline]
pub fn get_length(values: &[u8]) -> Option<usize> {
assert!(values.len() >= 4);
values
.get(0..4)
.map(|x| u32::from_le_bytes(x.try_into().unwrap()) as usize)
Expand Down
1 change: 1 addition & 0 deletions crates/polars-parquet/src/parquet/encoding/uleb128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub fn decode(values: &[u8]) -> (u64, usize) {
/// # Panic
/// This function may panic if `container.len() < 10` and `value` requires more bytes.
pub fn encode(mut value: u64, container: &mut [u8]) -> usize {
assert!(container.len() >= 10);
let mut consumed = 0;
let mut iter = container.iter_mut();
loop {
Expand Down

0 comments on commit 989eade

Please sign in to comment.