@@ -235,58 +235,37 @@ where
235235 Bound :: Included ( "wasi:io/[email protected] " ) , 236236 Bound :: Excluded ( "wasi:io/[email protected] " ) , 237237 ) )
238- . map ( |( name, instance) | {
239- instance
240- . get ( "error" )
241- . copied ( )
242- . with_context ( || format ! ( "{name} instance import missing `error` resource" ) )
243- } )
244- . collect :: < anyhow:: Result < Box < [ _ ] > > > ( ) ?;
238+ . flat_map ( |( _, instance) | instance. get ( "error" ) )
239+ . copied ( )
240+ . collect :: < Box < [ _ ] > > ( ) ;
245241 let io_pollable_tys = host_resources
246242 . range :: < str , _ > ( (
247243 Bound :: Included ( "wasi:io/[email protected] " ) , 248244 Bound :: Excluded ( "wasi:io/[email protected] " ) , 249245 ) )
250- . map ( |( name, instance) | {
251- instance
252- . get ( "pollable" )
253- . copied ( )
254- . with_context ( || format ! ( "{name} instance import missing `pollable` resource" ) )
255- } )
256- . collect :: < anyhow:: Result < Box < [ _ ] > > > ( ) ?;
246+ . flat_map ( |( _, instance) | instance. get ( "pollable" ) )
247+ . copied ( )
248+ . collect :: < Box < [ _ ] > > ( ) ;
257249 let io_input_stream_tys = host_resources
258250 . range :: < str , _ > ( (
259251 Bound :: Included ( "wasi:io/[email protected] " ) , 260252 Bound :: Excluded ( "wasi:io/[email protected] " ) , 261253 ) )
262- . map ( |( name, instance) | {
263- instance
264- . get ( "input-stream" )
265- . copied ( )
266- . with_context ( || format ! ( "{name} instance import missing `input-stream` resource" ) )
267- } )
268- . collect :: < anyhow:: Result < Box < [ _ ] > > > ( ) ?;
254+ . flat_map ( |( _, instance) | instance. get ( "input-stream" ) )
255+ . copied ( )
256+ . collect :: < Box < [ _ ] > > ( ) ;
269257 let io_output_stream_tys = host_resources
270258 . range :: < str , _ > ( (
271259 Bound :: Included ( "wasi:io/[email protected] " ) , 272260 Bound :: Excluded ( "wasi:io/[email protected] " ) , 273261 ) )
274- . map ( |( name, instance) | {
275- instance
276- . get ( "output-stream" )
277- . copied ( )
278- . with_context ( || format ! ( "{name} instance import missing `output-stream` resource" ) )
279- } )
280- . collect :: < anyhow:: Result < Box < [ _ ] > > > ( ) ?;
262+ . flat_map ( |( _, instance) | instance. get ( "output-stream" ) )
263+ . copied ( )
264+ . collect :: < Box < [ _ ] > > ( ) ;
281265 let rpc_err_ty = host_resources
282266 . get ( "wrpc:rpc/[email protected] " ) 283- . map ( |instance| {
284- instance
285- . get ( "error" )
286- . copied ( )
287- . context ( "`wrpc:rpc/[email protected] ` instance import missing `error` resource" ) 288- } )
289- . transpose ( ) ?;
267+ . and_then ( |instance| instance. get ( "error" ) )
268+ . copied ( ) ;
290269 // TODO: This should include `wasi:http` resources
291270 let host_resources = host_resources
292271 . into_iter ( )
0 commit comments