@@ -1075,6 +1075,7 @@ impl RawLua {
10751075
10761076 #[ cfg( feature = "async" ) ]
10771077 pub ( crate ) fn create_async_callback ( & self , func : AsyncCallback ) -> Result < Function > {
1078+ // Ensure that the coroutine library is loaded
10781079 #[ cfg( any( feature = "lua54" , feature = "lua53" , feature = "lua52" , feature = "luau" ) ) ]
10791080 unsafe {
10801081 if !( * self . extra . get ( ) ) . libs . contains ( StdLib :: COROUTINE ) {
@@ -1130,7 +1131,7 @@ impl RawLua {
11301131 }
11311132 Poll :: Ready ( nresults) => {
11321133 match nresults? {
1133- nresults @ 0 ..= 2 => {
1134+ nresults if nresults < 3 => {
11341135 // Fast path for up to 2 results without creating a table
11351136 ffi:: lua_pushinteger ( state, nresults as _ ) ;
11361137 if nresults > 0 {
@@ -1182,13 +1183,11 @@ impl RawLua {
11821183 let lua = self . lua ( ) ;
11831184 let coroutine = lua. globals ( ) . get :: < Table > ( "coroutine" ) ?;
11841185
1186+ // Prepare environment for the async poller
11851187 let env = lua. create_table_with_capacity ( 0 , 3 ) ?;
11861188 env. set ( "get_poll" , get_poll) ?;
1187- // Cache `yield` function
11881189 env. set ( "yield" , coroutine. get :: < Function > ( "yield" ) ?) ?;
1189- unsafe {
1190- env. set ( "unpack" , lua. create_c_function ( unpack) ?) ?;
1191- }
1190+ env. set ( "unpack" , unsafe { lua. create_c_function ( unpack) ? } ) ?;
11921191
11931192 lua. load (
11941193 r#"
0 commit comments