polars_arrow/array/binary/
fmt.rs1use std::fmt::{Debug, Formatter, Result, Write};
2
3use super::super::fmt::write_vec;
4use super::BinaryArray;
5use crate::offset::Offset;
6
7pub 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
14impl<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}