hooks 3.0.0-alpha.15

Compile-time, async hooks
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use std::pin::Pin;

pub fn pin_project_or_insert_with<T>(
    mut option: Pin<&mut Option<T>>,
    f: impl FnOnce() -> T,
) -> Pin<&mut T> {
    if option.is_none() {
        option.set(Some(f()));
    }

    option.as_pin_mut().unwrap()
}