From bc2a5121018f33eee9347dab4c1cbdb3622654fa Mon Sep 17 00:00:00 2001 From: Florian Dehau Date: Tue, 14 Apr 2020 18:56:00 +0200 Subject: [PATCH] feat: add missing `Clone` and `Copy` on types --- src/symbols.rs | 3 +++ src/widgets/barchart.rs | 1 + src/widgets/block.rs | 4 ++-- src/widgets/chart.rs | 4 ++++ src/widgets/clear.rs | 1 + src/widgets/gauge.rs | 1 + src/widgets/list.rs | 2 ++ src/widgets/mod.rs | 2 +- src/widgets/paragraph.rs | 1 + src/widgets/sparkline.rs | 1 + src/widgets/table.rs | 3 +++ src/widgets/tabs.rs | 1 + 12 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/symbols.rs b/src/symbols.rs index 2a24483..d4c5473 100644 --- a/src/symbols.rs +++ b/src/symbols.rs @@ -8,6 +8,7 @@ pub mod block { pub const ONE_QUARTER: &str = "▎"; pub const ONE_EIGHTH: &str = "▏"; + #[derive(Debug, Clone)] pub struct Set { pub full: &'static str, pub seven_eighths: &'static str, @@ -55,6 +56,7 @@ pub mod bar { pub const ONE_QUARTER: &str = "▂"; pub const ONE_EIGHTH: &str = "▁"; + #[derive(Debug, Clone)] pub struct Set { pub full: &'static str, pub seven_eighths: &'static str, @@ -141,6 +143,7 @@ pub mod line { pub const DOUBLE_CROSS: &str = "╬"; pub const THICK_CROSS: &str = "╋"; + #[derive(Debug, Clone)] pub struct Set { pub vertical: &'static str, pub horizontal: &'static str, diff --git a/src/widgets/barchart.rs b/src/widgets/barchart.rs index 5b86d05..f31eba2 100644 --- a/src/widgets/barchart.rs +++ b/src/widgets/barchart.rs @@ -25,6 +25,7 @@ use unicode_width::UnicodeWidthStr; /// .data(&[("B0", 0), ("B1", 2), ("B2", 4), ("B3", 3)]) /// .max(4); /// ``` +#[derive(Debug, Clone)] pub struct BarChart<'a> { /// Block to wrap the widget in block: Option>, diff --git a/src/widgets/block.rs b/src/widgets/block.rs index f65f77a..7fc4015 100644 --- a/src/widgets/block.rs +++ b/src/widgets/block.rs @@ -4,7 +4,7 @@ use crate::style::Style; use crate::symbols::line; use crate::widgets::{Borders, Widget}; -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Clone, Copy)] pub enum BorderType { Plain, Rounded, @@ -39,7 +39,7 @@ impl BorderType { /// .border_type(BorderType::Rounded) /// .style(Style::default().bg(Color::Black)); /// ``` -#[derive(Clone, Copy)] +#[derive(Debug, Clone, Copy)] pub struct Block<'a> { /// Optional title place on the upper left of the block title: Option<&'a str>, diff --git a/src/widgets/chart.rs b/src/widgets/chart.rs index 6cccded..82dbdd3 100644 --- a/src/widgets/chart.rs +++ b/src/widgets/chart.rs @@ -12,6 +12,7 @@ use std::{borrow::Cow, cmp::max}; use unicode_width::UnicodeWidthStr; /// An X or Y axis for the chart widget +#[derive(Debug, Clone)] pub struct Axis<'a, L> where L: AsRef + 'a, @@ -82,6 +83,7 @@ where } /// Used to determine which style of graphing to use +#[derive(Debug, Clone, Copy)] pub enum GraphType { /// Draw each point Scatter, @@ -90,6 +92,7 @@ pub enum GraphType { } /// A group of data points +#[derive(Debug, Clone)] pub struct Dataset<'a> { /// Name of the dataset (used in the legend if shown) name: Cow<'a, str>, @@ -217,6 +220,7 @@ impl Default for ChartLayout { /// .style(Style::default().fg(Color::Magenta)) /// .data(&[(4.0, 5.0), (5.0, 8.0), (7.66, 13.5)])]); /// ``` +#[derive(Debug, Clone)] pub struct Chart<'a, LX, LY> where LX: AsRef + 'a, diff --git a/src/widgets/clear.rs b/src/widgets/clear.rs index 82a7a90..71357f5 100644 --- a/src/widgets/clear.rs +++ b/src/widgets/clear.rs @@ -22,6 +22,7 @@ use crate::widgets::Widget; /// /// For a more complete example how to utilize `Clear` to realize popups see /// the example `examples/popup.rs` +#[derive(Debug, Clone)] pub struct Clear; impl Widget for Clear { diff --git a/src/widgets/gauge.rs b/src/widgets/gauge.rs index 381cea9..7415665 100644 --- a/src/widgets/gauge.rs +++ b/src/widgets/gauge.rs @@ -17,6 +17,7 @@ use crate::widgets::{Block, Widget}; /// .style(Style::default().fg(Color::White).bg(Color::Black).modifier(Modifier::ITALIC)) /// .percent(20); /// ``` +#[derive(Debug, Clone)] pub struct Gauge<'a> { block: Option>, ratio: f64, diff --git a/src/widgets/list.rs b/src/widgets/list.rs index ca0fa92..c829e8b 100644 --- a/src/widgets/list.rs +++ b/src/widgets/list.rs @@ -7,6 +7,7 @@ use crate::layout::{Corner, Rect}; use crate::style::Style; use crate::widgets::{Block, StatefulWidget, Text, Widget}; +#[derive(Debug, Clone)] pub struct ListState { offset: usize, selected: Option, @@ -48,6 +49,7 @@ impl ListState { /// .highlight_style(Style::default().modifier(Modifier::ITALIC)) /// .highlight_symbol(">>"); /// ``` +#[derive(Debug, Clone)] pub struct List<'b, L> where L: Iterator>, diff --git a/src/widgets/mod.rs b/src/widgets/mod.rs index 87255d2..17ef0ca 100644 --- a/src/widgets/mod.rs +++ b/src/widgets/mod.rs @@ -47,7 +47,7 @@ bitflags! { } } -#[derive(Clone, Debug, PartialEq)] +#[derive(Debug, Clone, PartialEq)] pub enum Text<'b> { Raw(Cow<'b, str>), Styled(Cow<'b, str>, Style), diff --git a/src/widgets/paragraph.rs b/src/widgets/paragraph.rs index d89486d..b5a57ce 100644 --- a/src/widgets/paragraph.rs +++ b/src/widgets/paragraph.rs @@ -34,6 +34,7 @@ fn get_line_offset(line_width: u16, text_area_width: u16, alignment: Alignment) /// .alignment(Alignment::Center) /// .wrap(true); /// ``` +#[derive(Debug, Clone)] pub struct Paragraph<'a, 't, T> where T: Iterator>, diff --git a/src/widgets/sparkline.rs b/src/widgets/sparkline.rs index 71987a2..a5718a4 100644 --- a/src/widgets/sparkline.rs +++ b/src/widgets/sparkline.rs @@ -20,6 +20,7 @@ use std::cmp::min; /// .max(5) /// .style(Style::default().fg(Color::Red).bg(Color::White)); /// ``` +#[derive(Debug, Clone)] pub struct Sparkline<'a> { /// A block to wrap the widget in block: Option>, diff --git a/src/widgets/table.rs b/src/widgets/table.rs index 55890b2..27e0677 100644 --- a/src/widgets/table.rs +++ b/src/widgets/table.rs @@ -16,6 +16,7 @@ use std::{ }; use unicode_width::UnicodeWidthStr; +#[derive(Debug, Clone)] pub struct TableState { offset: usize, selected: Option, @@ -44,6 +45,7 @@ impl TableState { } /// Holds data to be displayed in a Table widget +#[derive(Debug, Clone)] pub enum Row where D: Iterator, @@ -77,6 +79,7 @@ where /// .style(Style::default().fg(Color::White)) /// .column_spacing(1); /// ``` +#[derive(Debug, Clone)] pub struct Table<'a, H, R> { /// A block to wrap the widget in block: Option>, diff --git a/src/widgets/tabs.rs b/src/widgets/tabs.rs index 37abf02..f57bd8f 100644 --- a/src/widgets/tabs.rs +++ b/src/widgets/tabs.rs @@ -21,6 +21,7 @@ use crate::widgets::{Block, Widget}; /// .highlight_style(Style::default().fg(Color::Yellow)) /// .divider(DOT); /// ``` +#[derive(Debug, Clone)] pub struct Tabs<'a, T> where T: AsRef + 'a,