Derive more stuff

This commit is contained in:
Alexandre Bury 2020-07-13 12:54:03 -07:00
parent 96919c6561
commit d31d0d0d76
15 changed files with 25 additions and 25 deletions

View File

@ -1,7 +1,7 @@
//! Tools to control view alignment.
/// Specifies the alignment along both horizontal and vertical directions.
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Align {
/// Horizontal alignment policy
pub h: HAlign,
@ -62,7 +62,7 @@ impl Align {
}
/// Horizontal alignment
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum HAlign {
/// Place the element to the left of available space
Left,
@ -73,7 +73,7 @@ pub enum HAlign {
}
/// Vertical alignment
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum VAlign {
/// Place the element at the top of available space
Top,

View File

@ -30,7 +30,7 @@ use crate::Vec2;
use crate::XY;
/// Describes a vertical or horizontal orientation for a view.
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum Orientation {
/// Horizontal orientation
Horizontal,
@ -126,7 +126,7 @@ impl Orientation {
///
/// * Absolute directions are Up, Down, Left, and Right.
/// * Relative directions are Front and Back.
#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Direction {
/// An absolute direction.
Abs(Absolute),
@ -199,7 +199,7 @@ impl Direction {
}
/// Direction relative to an orientation.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Relative {
// TODO: handle right-to-left? (Arabic, ...)
/// Front relative direction.
@ -261,7 +261,7 @@ impl Relative {
}
/// Absolute direction (up, down, left, right).
#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Absolute {
/// Left
Left,

View File

@ -5,7 +5,7 @@ use crate::Vec2;
use std::ops::Add;
/// A non-empty rectangle on the 2D grid.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Rect {
/// Top-left corner, inclusive
top_left: Vec2,

View File

@ -1,7 +1,7 @@
use enumset::EnumSetType;
/// Text effect
#[derive(EnumSetType, Debug)]
#[derive(EnumSetType, Debug, Hash)]
pub enum Effect {
/// No effect
Simple,

View File

@ -4,7 +4,7 @@ use enumset::{enum_set, EnumSet};
/// Combine a color and an effect.
///
/// Represents any transformation that can be applied to text.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct Style {
/// Effect to apply.
///

View File

@ -4,7 +4,7 @@ use crate::With;
///
/// A row is made of offsets into a parent `String`.
/// The corresponding substring should take `width` cells when printed.
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Row {
/// Beginning of the row in the parent `String`.
pub start: usize,

View File

@ -3,7 +3,7 @@ use super::segment::Segment;
/// Non-splittable piece of text.
///
/// It is made of a list of segments of text.
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Chunk {
/// Total width of this chunk.
pub width: usize,
@ -81,7 +81,7 @@ impl Chunk {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Hash)]
/// Describes a part of a chunk.
///
/// Includes both length and width to ease some computations.

View File

@ -2,7 +2,7 @@ use super::Segment;
use crate::utils::span::{IndexedCow, Span, SpannedStr};
/// A list of segments representing a row of text
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Row {
/// List of segments
pub segments: Vec<Segment>,

View File

@ -1,7 +1,7 @@
use crate::utils::span::{IndexedCow, Span, SpannedStr, SpannedText};
/// Refers to a part of a span
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Segment {
/// ID of the span this segment refers to
pub span_id: usize,

View File

@ -8,14 +8,14 @@ use unicode_width::UnicodeWidthStr;
/// A string with associated spans.
///
/// Each span has an associated attribute `T`.
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct SpannedString<T> {
source: String,
spans: Vec<IndexedSpan<T>>,
}
/// The immutable, borrowed equivalent of `SpannedString`.
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct SpannedStr<'a, T> {
source: &'a str,
spans: &'a [IndexedSpan<T>],
@ -261,7 +261,7 @@ impl<'a, T> From<&'a SpannedString<T>> for SpannedStr<'a, T> {
}
/// An indexed span with an associated attribute.
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct IndexedSpan<T> {
/// Content of the span.
pub content: IndexedCow,
@ -280,7 +280,7 @@ impl<T> AsRef<IndexedCow> for IndexedSpan<T> {
}
/// A resolved span borrowing its source string.
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Span<'a, T> {
/// Content of this span.
pub content: &'a str,
@ -334,7 +334,7 @@ impl<T> IndexedSpan<T> {
}
/// A span of text that can be either owned, or indexed in another String.
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum IndexedCow {
/// Indexes content in a separate string.
Borrowed {

View File

@ -2,7 +2,7 @@ use crate::Vec2;
use std::ops::{Add, Div, Mul, Sub};
/// Four values representing each direction.
#[derive(Clone, Copy)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct Margins {
/// Left margin
pub left: usize,

View File

@ -52,7 +52,7 @@ impl Position {
}
/// Single-dimensional offset policy.
#[derive(PartialEq, Debug, Clone)]
#[derive(PartialEq, Eq, Debug, Clone, Copy, Hash)]
pub enum Offset {
/// In the center of the screen
Center,

View File

@ -5,7 +5,7 @@ use std::cmp::min;
/// This describes a possible behaviour for a [`ResizedView`].
///
/// [`ResizedView`]: crate::views::ResizedView
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum SizeConstraint {
/// No constraint imposed, the child view's response is used.
Free,

View File

@ -14,7 +14,7 @@ use std::cmp::max;
use unicode_width::UnicodeWidthStr;
/// Identifies currently focused element in [`Dialog`].
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum DialogFocus {
/// Content element focused
Content,

View File

@ -32,7 +32,7 @@ enum Placement {
}
/// Identifies a layer in a `StackView`.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum LayerPosition {
/// Starts from the back (bottom) of the stack.
FromBack(usize),