diff options
author | SoniEx2 <endermoneymod@gmail.com> | 2022-04-17 18:11:13 -0300 |
---|---|---|
committer | SoniEx2 <endermoneymod@gmail.com> | 2022-04-17 18:11:13 -0300 |
commit | e9b6186a1d5bf4fe342c89c256dfa27c30e16b0a (patch) | |
tree | 4ea765b62d69be1a10ded724b809b3060635e587 | |
parent | 11267ce31034f800e033ef98eff8b5979e6e8cd1 (diff) |
Tweak for_entry_mut
-rw-r--r-- | src/lib.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs index bff39e2..4bd5de3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -589,7 +589,21 @@ impl<'ph> PluginHandle<'ph> { } /// Operates on a virtual plugin. - pub fn for_entry_mut<F, R>(&mut self, entry: &mut PluginEntryHandle<'ph>, f: F) -> R where F: for<'eh> FnOnce(&mut PluginHandle<'eh>) -> R { + /// + /// # Examples + /// + /// ```no_run + /// use hexchat_unsafe_plugin::{PluginHandle}; + /// + /// fn contexts_can_be_passed_in(ph: &mut PluginHandle<'_>) { + /// let ctx = ph.get_context(); + /// let mut vplug = ph.plugingui_add("foo", "bar", "baz", "qux"); + /// ph.for_entry_mut(&mut vplug, |ph| { + /// ph.set_context(&ctx); + /// }); + /// } + /// ``` + pub fn for_entry_mut<'eh, F, R>(&mut self, entry: &mut PluginEntryHandle<'ph>, f: F) -> R where F: FnOnce(&mut PluginHandle<'eh>) -> R, 'ph: 'eh { // we're doing something kinda (very) weird here, but this is the only // way to get and set pluginprefs for virtual plugins. // this should be sound. |