diff options
author | SoniEx2 <endermoneymod@gmail.com> | 2022-12-04 16:43:07 -0300 |
---|---|---|
committer | SoniEx2 <endermoneymod@gmail.com> | 2022-12-04 16:43:07 -0300 |
commit | 72519f2161672a2edcd393a41f9f2cd01eddc22f (patch) | |
tree | e23cf5aae200616435d17970366834126f6e34cc /tests/ui/example_opaque_vs_drop.rs | |
parent | ba97c812bd97c9a086aea5b3ce89c87e4b0222ec (diff) |
Use a wrapper struct to enable closures
Diffstat (limited to 'tests/ui/example_opaque_vs_drop.rs')
-rw-r--r-- | tests/ui/example_opaque_vs_drop.rs | 25 |
1 files changed, 25 insertions, 0 deletions
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<Option<&'a Foo<'a>>>, +} + +impl<'a> Drop for Foo<'a> { + fn drop(&mut self) { + } +} + +struct FooKey; +opaque! { + impl Opaque for FooKey { + type Kind<'a> = Foo<'a>; + } +} + +fn main() { +} |