Skip to content

Commit 8c9f04e

Browse files
committed
Allow Into conversions on style arguments
1 parent 334b4b2 commit 8c9f04e

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

examples/scatter_svg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ fn main() {
44
let data = [(-3.0, 2.3), (-1.6, 5.3), (0.3, 0.7), (4.3, -1.4), (6.4, 4.3), (8.5, 3.7)];
55
let s1 = plotlib::scatter::Scatter::from_vec(&data).style(plotlib::scatter::Style::new()
66
.marker(plotlib::scatter::Marker::Square)
7-
.colour("#DD3355".into()));
7+
.colour("#DD3355"));
88
let s2 = plotlib::scatter::Scatter::from_vec(&[(-1.4, 2.5), (7.2, -0.3)])
9-
.style(plotlib::scatter::Style::new().colour("#35C788".into()));
9+
.style(plotlib::scatter::Style::new().colour("#35C788"));
1010
let v = plotlib::view::View::new()
1111
.add(&s1)
1212
.add(&s2)

src/scatter.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ impl Style {
4343
}
4444
}
4545

46-
pub fn marker(mut self, value: Marker) -> Self {
47-
self.marker = Some(value);
46+
pub fn marker<T>(mut self, value: T) -> Self where T: Into<Marker> {
47+
self.marker = Some(value.into());
4848
self
4949
}
5050

@@ -55,8 +55,8 @@ impl Style {
5555
}
5656
}
5757

58-
pub fn colour(mut self, value: String) -> Self {
59-
self.colour = Some(value);
58+
pub fn colour<T>(mut self, value: T) -> Self where T: Into<String> {
59+
self.colour = Some(value.into());
6060
self
6161
}
6262

0 commit comments

Comments
 (0)