From 7b69834651f76e8a2cdc5e76dbef6529ef59c2b1 Mon Sep 17 00:00:00 2001 From: SmnTin Date: Fri, 27 Mar 2026 12:05:57 +0100 Subject: [PATCH] Make `Coroutine::with_stack_unchecked` public --- src/coroutine.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/coroutine.rs b/src/coroutine.rs index f46b54a..7f3f7a8 100644 --- a/src/coroutine.rs +++ b/src/coroutine.rs @@ -191,7 +191,14 @@ impl Coroutine(stack: Stack, func: F) -> Self + /// + /// # Safety + /// The caller must ensure that all the data borrowed by `func` remains valid + /// from the moment the coroutine is created and until it is either driven to completion or dropped. + /// + /// If the coroutine is forgotten (with [`std::mem::forget`]), the stack memory cannot be reclaimed and reused, + /// and the data borrowed by `func` must remain valid indefinitely. + pub unsafe fn with_stack_unchecked(stack: Stack, func: F) -> Self where F: FnOnce(&Yielder, Input) -> Return, {