Amanieu / corosensei

A fast and safe implementation of stackful coroutines in Rust
Apache License 2.0
178 stars 13 forks source link

missing Clone impl on Yielder? #26

Closed carlsverre closed 4 months ago

carlsverre commented 4 months ago

According to the Yielder doc it should be safe to copy (but not safe to Send), however I don't see any way to make an owned copy of Yielder in the current API. Am I missing something? Currently I'm doing this which seems to work fine, but is not desirable for obvious reasons 😄

let y = unsafe {
    let mut y_copy: MaybeUninit<Yielder<bool, bool>> = MaybeUninit::uninit();
    std::ptr::copy_nonoverlapping(
        y as *const Yielder<bool, bool>,
        y_copy.as_mut_ptr(),
        1,
    );
    y_copy.assume_init()
};
Amanieu commented 4 months ago

This is a mistake in the documentation, which dates from an earlier design for the Yielder type. I've corrected the docs.