Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-arrow/src/array/binary/fmt.rs
6939 views
1
use std::fmt::{Debug, Formatter, Result, Write};
2
3
use super::super::fmt::write_vec;
4
use super::BinaryArray;
5
use crate::offset::Offset;
6
7
pub fn write_value<O: Offset, W: Write>(array: &BinaryArray<O>, index: usize, f: &mut W) -> Result {
8
let bytes = array.value(index);
9
let writer = |f: &mut W, index| write!(f, "{}", bytes[index]);
10
11
write_vec(f, writer, None, bytes.len(), "None", false)
12
}
13
14
impl<O: Offset> Debug for BinaryArray<O> {
15
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
16
let writer = |f: &mut Formatter, index| write_value(self, index, f);
17
18
let head = if O::IS_LARGE {
19
"LargeBinaryArray"
20
} else {
21
"BinaryArray"
22
};
23
write!(f, "{head}")?;
24
write_vec(f, writer, self.validity(), self.len(), "None", false)
25
}
26
}
27
28