pub struct Scope<'env> { /* private fields */ }
Expand description
An opaque utility for spawning local tasks that has access to the scope that Scope
has access to.
§Example
let listener = Async::new(TcpListener::bind("127.0.0.1:8080").unwrap()).unwrap();
let lala = String::from("hello");
{
let scope = Scope::new();
scope
.start(async {
loop {
let (client, _) = listener.accept().await.unwrap();
scope.spawn(async {
handle(client, &lala).await;
});
}
})
.await;
}
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<'env> !Freeze for Scope<'env>
impl<'env> !RefUnwindSafe for Scope<'env>
impl<'env> !Send for Scope<'env>
impl<'env> !Sync for Scope<'env>
impl<'env> Unpin for Scope<'env>
impl<'env> !UnwindSafe for Scope<'env>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more