]> git.proxmox.com Git - rustc.git/blob - vendor/tabled/src/settings/panel/footer.rs
New upstream version 1.75.0+dfsg1
[rustc.git] / vendor / tabled / src / settings / panel / footer.rs
1 use crate::{
2 grid::config::ColoredConfig,
3 grid::records::{ExactRecords, Records, RecordsMut, Resizable},
4 settings::TableOption,
5 };
6
7 use super::Panel;
8
9 /// Footer renders a [`Panel`] at the bottom.
10 /// See [`Panel`].
11 #[derive(Debug)]
12 pub struct Footer<S>(S);
13
14 impl<S> Footer<S> {
15 /// Creates a new object.
16 pub fn new(text: S) -> Self
17 where
18 S: AsRef<str>,
19 {
20 Self(text)
21 }
22 }
23
24 impl<S, R, D> TableOption<R, D, ColoredConfig> for Footer<S>
25 where
26 S: AsRef<str>,
27 R: Records + ExactRecords + Resizable + RecordsMut<String>,
28 {
29 fn change(self, records: &mut R, cfg: &mut ColoredConfig, dimension: &mut D) {
30 Panel::horizontal(records.count_rows(), self.0.as_ref()).change(records, cfg, dimension);
31 }
32 }