Remove code duplication using generics.

This commit is contained in:
Jordan Petridis
2018-02-09 08:43:47 +02:00
parent a96f4c57c9
commit 7690cb1356
+6 -10
View File
@@ -51,6 +51,12 @@ struct Title<S> {
state: S,
}
impl<S> Title<S> {
fn set_title(&self, s: &str) {
self.title.set_text(s);
}
}
impl Title<Normal> {
fn new(title: gtk::Label) -> Self {
Title {
@@ -58,16 +64,6 @@ impl Title<Normal> {
state: Normal {},
}
}
fn set_title(&self, s: &str) {
self.title.set_text(s);
}
}
impl Title<GreyedOut> {
fn set_title(&self, s: &str) {
self.title.set_text(s);
}
}
impl From<Title<Normal>> for Title<GreyedOut> {