@@ -31,7 +31,7 @@ pub const OCI_IMAGE_DIGEST_KEY: MetadataKey = MetadataKey::new("oci_image_digest
3131
3232/// Validation function type for ensuring that applications meet requirements
3333/// even with components filtered out.
34- pub type ValidatorFn = dyn Fn ( & App , & [ String ] ) -> anyhow:: Result < ( ) > ;
34+ pub type ValidatorFn = dyn Fn ( & App , & [ & str ] ) -> anyhow:: Result < ( ) > ;
3535
3636/// An `App` holds loaded configuration for a Spin application.
3737#[ derive( Debug , Clone ) ]
@@ -171,7 +171,7 @@ impl App {
171171 /// Introspects the LockedApp to find and selectively retain the triggers that correspond to those components
172172 fn retain_components (
173173 mut self ,
174- retained_components : & [ String ] ,
174+ retained_components : & [ & str ] ,
175175 validators : & [ & ValidatorFn ] ,
176176 ) -> Result < LockedApp > {
177177 self . validate_retained_components_exist ( retained_components) ?;
@@ -181,7 +181,7 @@ impl App {
181181 let ( component_ids, trigger_ids) : ( HashSet < String > , HashSet < String > ) = self
182182 . triggers ( )
183183 . filter_map ( |t| match t. component ( ) {
184- Ok ( comp) if retained_components. contains ( & comp. id ( ) . to_string ( ) ) => {
184+ Ok ( comp) if retained_components. contains ( & comp. id ( ) ) => {
185185 Some ( ( comp. id ( ) . to_owned ( ) , t. id ( ) . to_owned ( ) ) )
186186 }
187187 _ => None ,
@@ -195,13 +195,13 @@ impl App {
195195 }
196196
197197 /// Validates that all components specified to be retained actually exist in the app
198- fn validate_retained_components_exist ( & self , retained_components : & [ String ] ) -> Result < ( ) > {
198+ fn validate_retained_components_exist ( & self , retained_components : & [ & str ] ) -> Result < ( ) > {
199199 let app_components = self
200200 . components ( )
201201 . map ( |c| c. id ( ) . to_string ( ) )
202202 . collect :: < HashSet < _ > > ( ) ;
203203 for c in retained_components {
204- if !app_components. contains ( c) {
204+ if !app_components. contains ( * c) {
205205 return Err ( Error :: ValidationError ( anyhow:: anyhow!(
206206 "Specified component \" {c}\" not found in application"
207207 ) ) ) ;
@@ -320,7 +320,7 @@ struct CommonTriggerConfig {
320320/// Introspects the LockedApp to find and selectively retain the triggers that correspond to those components
321321pub fn retain_components (
322322 locked : LockedApp ,
323- components : & [ String ] ,
323+ components : & [ & str ] ,
324324 validators : & [ & ValidatorFn ] ,
325325) -> Result < LockedApp > {
326326 App :: new ( "unused" , locked) . retain_components ( components, validators)
@@ -332,7 +332,7 @@ mod test {
332332
333333 use super :: * ;
334334
335- fn does_nothing_validator ( _: & App , _: & [ String ] ) -> anyhow:: Result < ( ) > {
335+ fn does_nothing_validator ( _: & App , _: & [ & str ] ) -> anyhow:: Result < ( ) > {
336336 Ok ( ( ) )
337337 }
338338
@@ -351,12 +351,7 @@ mod test {
351351 source = "does-not-exist.wasm"
352352 } ;
353353 let mut locked_app = build_locked_app ( & manifest) . await . unwrap ( ) ;
354- locked_app = retain_components (
355- locked_app,
356- & [ "empty" . to_string ( ) ] ,
357- & [ & does_nothing_validator] ,
358- )
359- . unwrap ( ) ;
354+ locked_app = retain_components ( locked_app, & [ "empty" ] , & [ & does_nothing_validator] ) . unwrap ( ) ;
360355 let components = locked_app
361356 . components
362357 . iter ( )
0 commit comments