improv(context-drawer): import definitions and add map method
This commit is contained in:
parent
1abd6d7578
commit
7aadfe6ba6
3 changed files with 35 additions and 2 deletions
|
|
@ -62,4 +62,22 @@ impl<'a, Message: Clone + 'static> ContextDrawer<'a, Message> {
|
|||
self.footer = Some(footer.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn map<Out: Clone + 'static>(
|
||||
mut self,
|
||||
on_message: fn(Message) -> Out,
|
||||
) -> ContextDrawer<'a, Out> {
|
||||
ContextDrawer {
|
||||
title: self.title,
|
||||
content: self.content.map(on_message),
|
||||
header: self.header.map(|el| el.map(on_message)),
|
||||
footer: self.footer.map(|el| el.map(on_message)),
|
||||
on_close: on_message(self.on_close),
|
||||
header_actions: self
|
||||
.header_actions
|
||||
.into_iter()
|
||||
.map(|el| el.map(on_message))
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue