hamelin_lib 0.21.2

Core library for Hamelin query language
Documentation
use crate::types::Type;
use std::fmt::{Display, Formatter, Write};
use std::sync::Arc;

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Array {
    pub element_type: Arc<Type>,
}

impl Array {
    pub fn new(element_type: Type) -> Array {
        Array {
            element_type: Arc::new(element_type),
        }
    }

    pub fn fmt_indented(
        &self,
        f: &mut impl Write,
        indentation: usize,
        max_fields: usize,
    ) -> std::fmt::Result {
        write!(f, "array(")?;
        self.element_type.fmt_indented(f, indentation, max_fields)?;
        write!(f, ")")
    }

    pub fn subfields(&self) -> usize {
        self.element_type.subfields()
    }
}

impl Display for Array {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        self.fmt_indented(f, 0, usize::MAX)
    }
}