From 72519f2161672a2edcd393a41f9f2cd01eddc22f Mon Sep 17 00:00:00 2001 From: SoniEx2 Date: Sun, 4 Dec 2022 16:43:07 -0300 Subject: Use a wrapper struct to enable closures --- tests/ui/example_opaque_vs_drop.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/ui/example_opaque_vs_drop.rs (limited to 'tests/ui/example_opaque_vs_drop.rs') diff --git a/tests/ui/example_opaque_vs_drop.rs b/tests/ui/example_opaque_vs_drop.rs new file mode 100644 index 0000000..b2c1809 --- /dev/null +++ b/tests/ui/example_opaque_vs_drop.rs @@ -0,0 +1,25 @@ +//! Example of how `opaque!` prevents unsound `Drop`. +//! +//! NOTE: Also in trait `Opaque` documentation. Keep 'em in sync. + +use std::cell::Cell; +use selfref::opaque; + +struct Foo<'a> { + foo: Cell>>, +} + +impl<'a> Drop for Foo<'a> { + fn drop(&mut self) { + } +} + +struct FooKey; +opaque! { + impl Opaque for FooKey { + type Kind<'a> = Foo<'a>; + } +} + +fn main() { +} -- cgit 1.4.1