diff options
author | SoniEx2 <endermoneymod@gmail.com> | 2022-04-26 23:02:43 -0300 |
---|---|---|
committer | SoniEx2 <endermoneymod@gmail.com> | 2022-04-26 23:02:43 -0300 |
commit | ee7b71e9e1380592f47b78673bf127f1c18bbcb9 (patch) | |
tree | f9ce89d67da4aa1e7aa1e5dc94838bb160fc5626 | |
parent | cd895073b6f44239ba65147783e0d305b1d49a64 (diff) |
Tweak extra tests
-rw-r--r-- | src/extra_tests.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/extra_tests.rs b/src/extra_tests.rs index b64cc22..a81e312 100644 --- a/src/extra_tests.rs +++ b/src/extra_tests.rs @@ -30,3 +30,36 @@ //! }) //! } //! ``` +//! +//! ```compile_fail +//! use hexchat_unsafe_plugin::list::Contexts; +//! use hexchat_unsafe_plugin::PluginHandle; +//! +//! fn unsound(ph: &mut PluginHandle<'_>) { +//! ph.ensure_valid_context(|mut ph| { +//! let mut list = ph.list(&Contexts); +//! let context = list.next().unwrap(); +//! std::mem::forget(list); +//! let ctx = context.context(); +//! ph.set_context(&ctx); +//! }) +//! } +//! ``` +//! +//! ```no_run +//! use hexchat_unsafe_plugin::list::Contexts; +//! use hexchat_unsafe_plugin::PluginHandle; +//! +//! fn fine(ph: &mut PluginHandle<'_>) { +//! ph.ensure_valid_context(|mut ph| { +//! let mut list = ph.list(&Contexts); +//! let context = list.next().unwrap(); +//! write!(ph, "{}", context.name().unwrap()); +//! let ctx = context.context(); +//! let name = context.name().unwrap(); +//! drop(list); +//! ph.set_context(&ctx); +//! write!(ph, "{}", name); +//! }) +//! } +//! ``` |