Remove code duplication using generics.

This commit is contained in:
Jordan Petridis 2018-02-08 19:53:31 +02:00
parent a96f4c57c9
commit 7690cb1356
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6

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> {