papergrid/records/
exact_records.rs

1/// [`Records`] extension which guarantees the amount of rows.
2///
3/// [`Records`]: crate::records::Records
4pub trait ExactRecords {
5    /// Returns an exact amount of rows in records.
6    ///
7    /// It must be guaranteed that an iterator will yield this amount.
8    fn count_rows(&self) -> usize;
9}
10
11impl<T> ExactRecords for &T
12where
13    T: ExactRecords,
14{
15    fn count_rows(&self) -> usize {
16        T::count_rows(self)
17    }
18}
19
20#[cfg(feature = "std")]
21impl<T> ExactRecords for Vec<T> {
22    fn count_rows(&self) -> usize {
23        self.len()
24    }
25}
26
27impl<T> ExactRecords for [T] {
28    fn count_rows(&self) -> usize {
29        self.len()
30    }
31}