@@ -37,20 +37,20 @@ impl JsExportsInfo {
3737#[ napi]
3838impl JsExportsInfo {
3939 #[ napi( ts_args_type = "runtime: string | string[] | undefined" ) ]
40- pub fn is_used ( & self , js_runtime : Option < JsRuntimeSpec > ) -> napi:: Result < bool > {
40+ pub fn is_used ( & self , js_runtime : JsRuntimeSpec ) -> napi:: Result < bool > {
4141 let module_graph = self . as_ref ( ) ?;
4242 let runtime: Option < RuntimeSpec > = js_runtime. map ( |js_rt| match js_rt {
43- Either :: A ( str) => vec ! [ str ] . into_iter ( ) . map ( Arc :: from) . collect ( ) ,
43+ Either :: A ( str) => std :: iter :: once ( str ) . map ( Arc :: from) . collect ( ) ,
4444 Either :: B ( vec) => vec. into_iter ( ) . map ( Arc :: from) . collect ( ) ,
4545 } ) ;
4646 Ok ( self . exports_info . is_used ( & module_graph, runtime. as_ref ( ) ) )
4747 }
4848
4949 #[ napi( ts_args_type = "runtime: string | string[] | undefined" ) ]
50- pub fn is_module_used ( & self , js_runtime : Option < JsRuntimeSpec > ) -> napi:: Result < bool > {
50+ pub fn is_module_used ( & self , js_runtime : JsRuntimeSpec ) -> napi:: Result < bool > {
5151 let module_graph = self . as_ref ( ) ?;
5252 let runtime: Option < RuntimeSpec > = js_runtime. map ( |js_rt| match js_rt {
53- Either :: A ( str) => vec ! [ str ] . into_iter ( ) . map ( Arc :: from) . collect ( ) ,
53+ Either :: A ( str) => std :: iter :: once ( str ) . map ( Arc :: from) . collect ( ) ,
5454 Either :: B ( vec) => vec. into_iter ( ) . map ( Arc :: from) . collect ( ) ,
5555 } ) ;
5656 Ok (
@@ -61,13 +61,10 @@ impl JsExportsInfo {
6161 }
6262
6363 #[ napi( ts_args_type = "runtime: string | string[] | undefined" ) ]
64- pub fn set_used_in_unknown_way (
65- & mut self ,
66- js_runtime : Option < JsRuntimeSpec > ,
67- ) -> napi:: Result < bool > {
64+ pub fn set_used_in_unknown_way ( & mut self , js_runtime : JsRuntimeSpec ) -> napi:: Result < bool > {
6865 let mut module_graph = self . as_mut ( ) ?;
6966 let runtime: Option < RuntimeSpec > = js_runtime. map ( |js_rt| match js_rt {
70- Either :: A ( str) => vec ! [ str ] . into_iter ( ) . map ( Arc :: from) . collect ( ) ,
67+ Either :: A ( str) => std :: iter :: once ( str ) . map ( Arc :: from) . collect ( ) ,
7168 Either :: B ( vec) => vec. into_iter ( ) . map ( Arc :: from) . collect ( ) ,
7269 } ) ;
7370 Ok (
@@ -84,15 +81,15 @@ impl JsExportsInfo {
8481 pub fn get_used (
8582 & self ,
8683 js_name : Either < String , Vec < String > > ,
87- js_runtime : Option < JsRuntimeSpec > ,
84+ js_runtime : JsRuntimeSpec ,
8885 ) -> napi:: Result < u32 > {
8986 let module_graph = self . as_ref ( ) ?;
9087 let name = match js_name {
9188 Either :: A ( s) => UsedName :: Str ( s. into ( ) ) ,
9289 Either :: B ( v) => UsedName :: Vec ( v. into_iter ( ) . map ( Into :: into) . collect :: < Vec < _ > > ( ) ) ,
9390 } ;
9491 let runtime: Option < RuntimeSpec > = js_runtime. map ( |js_rt| match js_rt {
95- Either :: A ( str) => vec ! [ str ] . into_iter ( ) . map ( Arc :: from) . collect ( ) ,
92+ Either :: A ( str) => std :: iter :: once ( str ) . map ( Arc :: from) . collect ( ) ,
9693 Either :: B ( vec) => vec. into_iter ( ) . map ( Arc :: from) . collect ( ) ,
9794 } ) ;
9895 Ok (
0 commit comments