feat: add missing `Clone` and `Copy` on types

pull/269/head
Florian Dehau 4 years ago
parent 4f728d363f
commit bc2a512101

@ -8,6 +8,7 @@ pub mod block {
pub const ONE_QUARTER: &str = "▎"; pub const ONE_QUARTER: &str = "▎";
pub const ONE_EIGHTH: &str = "▏"; pub const ONE_EIGHTH: &str = "▏";
#[derive(Debug, Clone)]
pub struct Set { pub struct Set {
pub full: &'static str, pub full: &'static str,
pub seven_eighths: &'static str, pub seven_eighths: &'static str,
@ -55,6 +56,7 @@ pub mod bar {
pub const ONE_QUARTER: &str = "▂"; pub const ONE_QUARTER: &str = "▂";
pub const ONE_EIGHTH: &str = "▁"; pub const ONE_EIGHTH: &str = "▁";
#[derive(Debug, Clone)]
pub struct Set { pub struct Set {
pub full: &'static str, pub full: &'static str,
pub seven_eighths: &'static str, pub seven_eighths: &'static str,
@ -141,6 +143,7 @@ pub mod line {
pub const DOUBLE_CROSS: &str = "╬"; pub const DOUBLE_CROSS: &str = "╬";
pub const THICK_CROSS: &str = "╋"; pub const THICK_CROSS: &str = "╋";
#[derive(Debug, Clone)]
pub struct Set { pub struct Set {
pub vertical: &'static str, pub vertical: &'static str,
pub horizontal: &'static str, pub horizontal: &'static str,

@ -25,6 +25,7 @@ use unicode_width::UnicodeWidthStr;
/// .data(&[("B0", 0), ("B1", 2), ("B2", 4), ("B3", 3)]) /// .data(&[("B0", 0), ("B1", 2), ("B2", 4), ("B3", 3)])
/// .max(4); /// .max(4);
/// ``` /// ```
#[derive(Debug, Clone)]
pub struct BarChart<'a> { pub struct BarChart<'a> {
/// Block to wrap the widget in /// Block to wrap the widget in
block: Option<Block<'a>>, block: Option<Block<'a>>,

@ -4,7 +4,7 @@ use crate::style::Style;
use crate::symbols::line; use crate::symbols::line;
use crate::widgets::{Borders, Widget}; use crate::widgets::{Borders, Widget};
#[derive(Debug, Copy, Clone)] #[derive(Debug, Clone, Copy)]
pub enum BorderType { pub enum BorderType {
Plain, Plain,
Rounded, Rounded,
@ -39,7 +39,7 @@ impl BorderType {
/// .border_type(BorderType::Rounded) /// .border_type(BorderType::Rounded)
/// .style(Style::default().bg(Color::Black)); /// .style(Style::default().bg(Color::Black));
/// ``` /// ```
#[derive(Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub struct Block<'a> { pub struct Block<'a> {
/// Optional title place on the upper left of the block /// Optional title place on the upper left of the block
title: Option<&'a str>, title: Option<&'a str>,

@ -12,6 +12,7 @@ use std::{borrow::Cow, cmp::max};
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;
/// An X or Y axis for the chart widget /// An X or Y axis for the chart widget
#[derive(Debug, Clone)]
pub struct Axis<'a, L> pub struct Axis<'a, L>
where where
L: AsRef<str> + 'a, L: AsRef<str> + 'a,
@ -82,6 +83,7 @@ where
} }
/// Used to determine which style of graphing to use /// Used to determine which style of graphing to use
#[derive(Debug, Clone, Copy)]
pub enum GraphType { pub enum GraphType {
/// Draw each point /// Draw each point
Scatter, Scatter,
@ -90,6 +92,7 @@ pub enum GraphType {
} }
/// A group of data points /// A group of data points
#[derive(Debug, Clone)]
pub struct Dataset<'a> { pub struct Dataset<'a> {
/// Name of the dataset (used in the legend if shown) /// Name of the dataset (used in the legend if shown)
name: Cow<'a, str>, name: Cow<'a, str>,
@ -217,6 +220,7 @@ impl Default for ChartLayout {
/// .style(Style::default().fg(Color::Magenta)) /// .style(Style::default().fg(Color::Magenta))
/// .data(&[(4.0, 5.0), (5.0, 8.0), (7.66, 13.5)])]); /// .data(&[(4.0, 5.0), (5.0, 8.0), (7.66, 13.5)])]);
/// ``` /// ```
#[derive(Debug, Clone)]
pub struct Chart<'a, LX, LY> pub struct Chart<'a, LX, LY>
where where
LX: AsRef<str> + 'a, LX: AsRef<str> + 'a,

@ -22,6 +22,7 @@ use crate::widgets::Widget;
/// ///
/// For a more complete example how to utilize `Clear` to realize popups see /// For a more complete example how to utilize `Clear` to realize popups see
/// the example `examples/popup.rs` /// the example `examples/popup.rs`
#[derive(Debug, Clone)]
pub struct Clear; pub struct Clear;
impl Widget for Clear { impl Widget for Clear {

@ -17,6 +17,7 @@ use crate::widgets::{Block, Widget};
/// .style(Style::default().fg(Color::White).bg(Color::Black).modifier(Modifier::ITALIC)) /// .style(Style::default().fg(Color::White).bg(Color::Black).modifier(Modifier::ITALIC))
/// .percent(20); /// .percent(20);
/// ``` /// ```
#[derive(Debug, Clone)]
pub struct Gauge<'a> { pub struct Gauge<'a> {
block: Option<Block<'a>>, block: Option<Block<'a>>,
ratio: f64, ratio: f64,

@ -7,6 +7,7 @@ use crate::layout::{Corner, Rect};
use crate::style::Style; use crate::style::Style;
use crate::widgets::{Block, StatefulWidget, Text, Widget}; use crate::widgets::{Block, StatefulWidget, Text, Widget};
#[derive(Debug, Clone)]
pub struct ListState { pub struct ListState {
offset: usize, offset: usize,
selected: Option<usize>, selected: Option<usize>,
@ -48,6 +49,7 @@ impl ListState {
/// .highlight_style(Style::default().modifier(Modifier::ITALIC)) /// .highlight_style(Style::default().modifier(Modifier::ITALIC))
/// .highlight_symbol(">>"); /// .highlight_symbol(">>");
/// ``` /// ```
#[derive(Debug, Clone)]
pub struct List<'b, L> pub struct List<'b, L>
where where
L: Iterator<Item = Text<'b>>, L: Iterator<Item = Text<'b>>,

@ -47,7 +47,7 @@ bitflags! {
} }
} }
#[derive(Clone, Debug, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub enum Text<'b> { pub enum Text<'b> {
Raw(Cow<'b, str>), Raw(Cow<'b, str>),
Styled(Cow<'b, str>, Style), Styled(Cow<'b, str>, Style),

@ -34,6 +34,7 @@ fn get_line_offset(line_width: u16, text_area_width: u16, alignment: Alignment)
/// .alignment(Alignment::Center) /// .alignment(Alignment::Center)
/// .wrap(true); /// .wrap(true);
/// ``` /// ```
#[derive(Debug, Clone)]
pub struct Paragraph<'a, 't, T> pub struct Paragraph<'a, 't, T>
where where
T: Iterator<Item = &'t Text<'t>>, T: Iterator<Item = &'t Text<'t>>,

@ -20,6 +20,7 @@ use std::cmp::min;
/// .max(5) /// .max(5)
/// .style(Style::default().fg(Color::Red).bg(Color::White)); /// .style(Style::default().fg(Color::Red).bg(Color::White));
/// ``` /// ```
#[derive(Debug, Clone)]
pub struct Sparkline<'a> { pub struct Sparkline<'a> {
/// A block to wrap the widget in /// A block to wrap the widget in
block: Option<Block<'a>>, block: Option<Block<'a>>,

@ -16,6 +16,7 @@ use std::{
}; };
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;
#[derive(Debug, Clone)]
pub struct TableState { pub struct TableState {
offset: usize, offset: usize,
selected: Option<usize>, selected: Option<usize>,
@ -44,6 +45,7 @@ impl TableState {
} }
/// Holds data to be displayed in a Table widget /// Holds data to be displayed in a Table widget
#[derive(Debug, Clone)]
pub enum Row<D> pub enum Row<D>
where where
D: Iterator, D: Iterator,
@ -77,6 +79,7 @@ where
/// .style(Style::default().fg(Color::White)) /// .style(Style::default().fg(Color::White))
/// .column_spacing(1); /// .column_spacing(1);
/// ``` /// ```
#[derive(Debug, Clone)]
pub struct Table<'a, H, R> { pub struct Table<'a, H, R> {
/// A block to wrap the widget in /// A block to wrap the widget in
block: Option<Block<'a>>, block: Option<Block<'a>>,

@ -21,6 +21,7 @@ use crate::widgets::{Block, Widget};
/// .highlight_style(Style::default().fg(Color::Yellow)) /// .highlight_style(Style::default().fg(Color::Yellow))
/// .divider(DOT); /// .divider(DOT);
/// ``` /// ```
#[derive(Debug, Clone)]
pub struct Tabs<'a, T> pub struct Tabs<'a, T>
where where
T: AsRef<str> + 'a, T: AsRef<str> + 'a,

Loading…
Cancel
Save