Remove code duplication using generics.
This commit is contained in:
parent
a96f4c57c9
commit
7690cb1356
@ -51,6 +51,12 @@ struct Title<S> {
|
|||||||
state: S,
|
state: S,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<S> Title<S> {
|
||||||
|
fn set_title(&self, s: &str) {
|
||||||
|
self.title.set_text(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Title<Normal> {
|
impl Title<Normal> {
|
||||||
fn new(title: gtk::Label) -> Self {
|
fn new(title: gtk::Label) -> Self {
|
||||||
Title {
|
Title {
|
||||||
@ -58,16 +64,6 @@ impl Title<Normal> {
|
|||||||
state: 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> {
|
impl From<Title<Normal>> for Title<GreyedOut> {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user