Path: blob/main/crates/test-programs/src/bin/async_borrowing_callee.rs
1693 views
mod bindings {1wit_bindgen::generate!({2path: "../misc/component-async-tests/wit",3world: "borrowing-callee",4});56use super::Component;7export!(Component);8}910use bindings::{11exports::local::local::{borrowing::Guest as Borrowing, run_bool::Guest as RunBool},12local::local::borrowing_types::X,13};1415struct Component;1617impl Borrowing for Component {18async fn foo(x: &X, misbehave: bool) {19let handle = x.handle();20wit_bindgen::spawn(async move {21if misbehave {22unsafe { X::from_handle(handle) }.foo();23}24});25x.foo();26}27}2829impl RunBool for Component {30async fn run(misbehave: bool) {31Self::foo(&X::new(), misbehave).await32}33}3435// Unused function; required since this file is built as a `bin`:36fn main() {}373839