1#![doc = include_str!("resource.md")]
2
3use alloc::boxed::Box;
4
5pub trait Resource: 'static {
6 type Value: ?Sized;
7 fn as_ptr(&self) -> *const Self::Value;
8}
9
10pub trait ResourceMut: Resource {
11 fn as_ptr_mut(&mut self) -> *mut Self::Value;
12}
13
14impl<T: 'static + ?Sized> Resource for Box<T> {
15 type Value = T;
16 fn as_ptr(&self) -> *const Self::Value {
17 &raw const **self
18 }
19}
20
21impl<T: 'static + ?Sized> ResourceMut for Box<T> {
22 fn as_ptr_mut(&mut self) -> *mut Self::Value {
23 &raw mut **self
24 }
25}