pidl_bud/
lib.rs

1use higher_kinded_types::ForLifetime;
2use higher_kinded_types::ForLt;
3
4pub mod rexport {
5    pub extern crate higher_kinded_types;
6}
7pub trait Bud<'a, C: ForLifetime + ?Sized> {
8    fn bud<'b>(&'b mut self) -> C::Of<'b>;
9}
10impl<'a, C: ?Sized + for<'b> ForLifetime<Of<'b> = &'b mut T>, T: ?Sized> Bud<'a, C> for &'a mut T {
11    fn bud<'b>(&'b mut self) -> <C as ForLifetime>::Of<'b> {
12        &mut **self
13    }
14}
15impl<'a, C: ?Sized + for<'b> ForLifetime<Of<'b> = ()>> Bud<'a, C> for () {
16    fn bud<'b>(&'b mut self) -> <C as ForLifetime>::Of<'b> {
17        ()
18    }
19}
20
21#[cfg(feature = "wasm_runtime_layer")]
22const _: () = {
23    use wasm_runtime_layer::{backend::WasmEngine, AsContextMut, StoreContextMut};
24    impl<
25            'a,
26            E: WasmEngine,
27            U,
28            C: ?Sized + for<'b> ForLifetime<Of<'b> = StoreContextMut<'b, U, E>>,
29        > Bud<'a, C> for StoreContextMut<'a, U, E>
30    {
31        fn bud<'b>(&'b mut self) -> <C as ForLifetime>::Of<'b> {
32            self.as_context_mut()
33        }
34    }
35};
36pub trait Budding: for<'a> ForLifetime<Of<'a>: Bud<'a, Self>> {}
37impl<T: for<'a> ForLifetime<Of<'a>: Bud<'a, Self>>> Budding for T {}