//! Binding relations: rows over named (variable) columns. //! //! Every operator in this crate (after the initial atom scan) consumes and //! produces [`Relation`]s. Column names are variable names; a value at column //! `i` of a row is the value bound to variable `columns[i]` in that solution. use crate::value::Value; #[derive(Debug, Clone)] pub struct Relation { pub columns: Vec, pub rows: Vec>, } impl Relation { #[must_use] pub fn new(columns: Vec) -> Self { Self { columns, rows: Vec::new(), } } /// # Panics /// Panics if `row.len() != self.columns.len()`. pub fn push(&mut self, row: Vec) { assert_eq!( row.len(), self.columns.len(), "row arity mismatch: expected {}, got {}", self.columns.len(), row.len(), ); self.rows.push(row); } }