/rust/registry/src/index.crates.io-1949cf8c6b5b557f/criterion-plot-0.5.0/src/display.rs
Line | Count | Source |
1 | | use std::borrow::Cow; |
2 | | |
3 | | use crate::key::{Horizontal, Justification, Order, Stacked, Vertical}; |
4 | | use crate::{Axes, Axis, Color, Display, Grid, LineType, PointType, Terminal}; |
5 | | |
6 | | impl Display<&'static str> for Axis { |
7 | 0 | fn display(&self) -> &'static str { |
8 | 0 | match *self { |
9 | 0 | Axis::BottomX => "x", |
10 | 0 | Axis::LeftY => "y", |
11 | 0 | Axis::RightY => "y2", |
12 | 0 | Axis::TopX => "x2", |
13 | | } |
14 | 0 | } |
15 | | } |
16 | | |
17 | | impl Display<&'static str> for Axes { |
18 | 0 | fn display(&self) -> &'static str { |
19 | 0 | match *self { |
20 | 0 | Axes::BottomXLeftY => "x1y1", |
21 | 0 | Axes::BottomXRightY => "x1y2", |
22 | 0 | Axes::TopXLeftY => "x2y1", |
23 | 0 | Axes::TopXRightY => "x2y2", |
24 | | } |
25 | 0 | } |
26 | | } |
27 | | |
28 | | impl Display<Cow<'static, str>> for Color { |
29 | 0 | fn display(&self) -> Cow<'static, str> { |
30 | 0 | match *self { |
31 | 0 | Color::Black => Cow::from("black"), |
32 | 0 | Color::Blue => Cow::from("blue"), |
33 | 0 | Color::Cyan => Cow::from("cyan"), |
34 | 0 | Color::DarkViolet => Cow::from("dark-violet"), |
35 | 0 | Color::ForestGreen => Cow::from("forest-green"), |
36 | 0 | Color::Gold => Cow::from("gold"), |
37 | 0 | Color::Gray => Cow::from("gray"), |
38 | 0 | Color::Green => Cow::from("green"), |
39 | 0 | Color::Magenta => Cow::from("magenta"), |
40 | 0 | Color::Red => Cow::from("red"), |
41 | 0 | Color::Rgb(r, g, b) => Cow::from(format!("#{:02x}{:02x}{:02x}", r, g, b)), |
42 | 0 | Color::White => Cow::from("white"), |
43 | 0 | Color::Yellow => Cow::from("yellow"), |
44 | | } |
45 | 0 | } |
46 | | } |
47 | | |
48 | | impl Display<&'static str> for Grid { |
49 | 0 | fn display(&self) -> &'static str { |
50 | 0 | match *self { |
51 | 0 | Grid::Major => "", |
52 | 0 | Grid::Minor => "m", |
53 | | } |
54 | 0 | } |
55 | | } |
56 | | |
57 | | impl Display<&'static str> for Horizontal { |
58 | 0 | fn display(&self) -> &'static str { |
59 | 0 | match *self { |
60 | 0 | Horizontal::Center => "center", |
61 | 0 | Horizontal::Left => "left", |
62 | 0 | Horizontal::Right => "right", |
63 | | } |
64 | 0 | } |
65 | | } |
66 | | |
67 | | impl Display<&'static str> for Justification { |
68 | 0 | fn display(&self) -> &'static str { |
69 | 0 | match *self { |
70 | 0 | Justification::Left => "Left", |
71 | 0 | Justification::Right => "Right", |
72 | | } |
73 | 0 | } |
74 | | } |
75 | | |
76 | | impl Display<&'static str> for LineType { |
77 | 0 | fn display(&self) -> &'static str { |
78 | 0 | match *self { |
79 | 0 | LineType::Dash => "2", |
80 | 0 | LineType::Dot => "3", |
81 | 0 | LineType::DotDash => "4", |
82 | 0 | LineType::DotDotDash => "5", |
83 | 0 | LineType::SmallDot => "0", |
84 | 0 | LineType::Solid => "1", |
85 | | } |
86 | 0 | } |
87 | | } |
88 | | |
89 | | impl Display<&'static str> for Order { |
90 | 0 | fn display(&self) -> &'static str { |
91 | 0 | match *self { |
92 | 0 | Order::TextSample => "noreverse", |
93 | 0 | Order::SampleText => "reverse", |
94 | | } |
95 | 0 | } |
96 | | } |
97 | | |
98 | | impl Display<&'static str> for PointType { |
99 | 0 | fn display(&self) -> &'static str { |
100 | 0 | match *self { |
101 | 0 | PointType::Circle => "6", |
102 | 0 | PointType::FilledCircle => "7", |
103 | 0 | PointType::FilledSquare => "5", |
104 | 0 | PointType::FilledTriangle => "9", |
105 | 0 | PointType::Plus => "1", |
106 | 0 | PointType::Square => "4", |
107 | 0 | PointType::Star => "3", |
108 | 0 | PointType::Triangle => "8", |
109 | 0 | PointType::X => "2", |
110 | | } |
111 | 0 | } |
112 | | } |
113 | | |
114 | | impl Display<&'static str> for Stacked { |
115 | 0 | fn display(&self) -> &'static str { |
116 | 0 | match *self { |
117 | 0 | Stacked::Horizontally => "horizontal", |
118 | 0 | Stacked::Vertically => "vertical", |
119 | | } |
120 | 0 | } |
121 | | } |
122 | | |
123 | | impl Display<&'static str> for Terminal { |
124 | 0 | fn display(&self) -> &'static str { |
125 | 0 | match *self { |
126 | 0 | Terminal::Svg => "svg dynamic", |
127 | | } |
128 | 0 | } |
129 | | } |
130 | | |
131 | | impl Display<&'static str> for Vertical { |
132 | 0 | fn display(&self) -> &'static str { |
133 | 0 | match *self { |
134 | 0 | Vertical::Bottom => "bottom", |
135 | 0 | Vertical::Center => "center", |
136 | 0 | Vertical::Top => "top", |
137 | | } |
138 | 0 | } |
139 | | } |