@@ -84,7 +84,7 @@ impl ArgCoercer {
84
84
} ;
85
85
86
86
for key in kv. keys ( ) {
87
- if !vec ! [ "file" , "media_type" ] . contains ( & key. as_str ( ) ) {
87
+ if ![ "file" , "media_type" ] . contains ( & key. as_str ( ) ) {
88
88
scope. push_error ( format ! (
89
89
"Invalid property `{}` on file {}: `media_type` is the only supported property" ,
90
90
key,
@@ -95,7 +95,7 @@ impl ArgCoercer {
95
95
match self . span_path . as_ref ( ) {
96
96
Some ( span_path) => {
97
97
Ok ( BamlValue :: Media ( baml_types:: BamlMedia :: file (
98
- media_type. clone ( ) ,
98
+ * media_type,
99
99
span_path. clone ( ) ,
100
100
s. to_string ( ) ,
101
101
mime_type,
@@ -118,7 +118,7 @@ impl ArgCoercer {
118
118
None => None ,
119
119
} ;
120
120
for key in kv. keys ( ) {
121
- if !vec ! [ "url" , "media_type" ] . contains ( & key. as_str ( ) ) {
121
+ if ![ "url" , "media_type" ] . contains ( & key. as_str ( ) ) {
122
122
scope. push_error ( format ! (
123
123
"Invalid property `{}` on url {}: `media_type` is the only supported property" ,
124
124
key,
@@ -127,7 +127,7 @@ impl ArgCoercer {
127
127
}
128
128
}
129
129
Ok ( BamlValue :: Media ( baml_types:: BamlMedia :: url (
130
- media_type. clone ( ) ,
130
+ * media_type,
131
131
s. to_string ( ) ,
132
132
mime_type,
133
133
) ) )
@@ -143,7 +143,7 @@ impl ArgCoercer {
143
143
None => None ,
144
144
} ;
145
145
for key in kv. keys ( ) {
146
- if !vec ! [ "base64" , "media_type" ] . contains ( & key. as_str ( ) ) {
146
+ if ![ "base64" , "media_type" ] . contains ( & key. as_str ( ) ) {
147
147
scope. push_error ( format ! (
148
148
"Invalid property `{}` on base64 {}: `media_type` is the only supported property" ,
149
149
key,
@@ -152,7 +152,7 @@ impl ArgCoercer {
152
152
}
153
153
}
154
154
Ok ( BamlValue :: Media ( baml_types:: BamlMedia :: base64 (
155
- media_type. clone ( ) ,
155
+ * media_type,
156
156
s. to_string ( ) ,
157
157
mime_type,
158
158
) ) )
@@ -177,7 +177,7 @@ impl ArgCoercer {
177
177
( FieldType :: Enum ( name) , _) => match value {
178
178
BamlValue :: String ( s) => {
179
179
if let Ok ( e) = ir. find_enum ( name) {
180
- if e. walk_values ( ) . find ( |v| v. item . elem . 0 == * s) . is_some ( ) {
180
+ if e. walk_values ( ) . any ( |v| v. item . elem . 0 == * s) {
181
181
Ok ( BamlValue :: Enum ( name. to_string ( ) , s. to_string ( ) ) )
182
182
} else {
183
183
scope. push_error ( format ! (
@@ -279,7 +279,7 @@ impl ArgCoercer {
279
279
}
280
280
} ,
281
281
( FieldType :: Tuple ( _) , _) => {
282
- scope. push_error ( format ! ( "Tuples are not yet supported" ) ) ;
282
+ scope. push_error ( "Tuples are not yet supported" . to_string ( ) ) ;
283
283
Err ( ( ) )
284
284
}
285
285
( FieldType :: Map ( k, v) , _) => {
@@ -310,10 +310,8 @@ impl ArgCoercer {
310
310
let mut scope = ScopeStack :: new ( ) ;
311
311
if first_good_result. is_err ( ) {
312
312
let result = self . coerce_arg ( ir, option, value, & mut scope) ;
313
- if !scope. has_errors ( ) {
314
- if first_good_result. is_err ( ) {
315
- first_good_result = result
316
- }
313
+ if !scope. has_errors ( ) && first_good_result. is_err ( ) {
314
+ first_good_result = result
317
315
}
318
316
}
319
317
}
@@ -346,7 +344,6 @@ impl ArgCoercer {
346
344
let search_for_failures_result = first_failing_assert_nested ( ir, & value, field_type)
347
345
. map_err ( |e| {
348
346
scope. push_error ( format ! ( "Failed to evaluate assert: {:?}" , e) ) ;
349
- ( )
350
347
} ) ?;
351
348
match search_for_failures_result {
352
349
Some ( Constraint {
@@ -378,7 +375,7 @@ fn first_failing_assert_nested<'a>(
378
375
. filter_map ( |c| {
379
376
let constraint = c. clone ( ) ;
380
377
let baml_value: BamlValue = value_node. into ( ) ;
381
- let result = evaluate_predicate ( & & baml_value, & c. expression ) . map_err ( |e| {
378
+ let result = evaluate_predicate ( & baml_value, & c. expression ) . map_err ( |e| {
382
379
anyhow:: anyhow!( format!( "Error evaluating constraint: {:?}" , e) )
383
380
} ) ;
384
381
match result {
@@ -395,8 +392,7 @@ fn first_failing_assert_nested<'a>(
395
392
} )
396
393
. collect :: < Vec < _ > > ( )
397
394
} )
398
- . map ( |x| x. into_iter ( ) )
399
- . flatten ( )
395
+ . flat_map ( |x| x. into_iter ( ) )
400
396
. next ( ) ;
401
397
first_failure. transpose ( )
402
398
}
0 commit comments