From e9b6186a1d5bf4fe342c89c256dfa27c30e16b0a Mon Sep 17 00:00:00 2001 From: SoniEx2 Date: Sun, 17 Apr 2022 18:11:13 -0300 Subject: Tweak for_entry_mut --- src/lib.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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(&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. -- cgit 1.4.1