@@ -186,8 +186,12 @@ impl TryIntoValue for RustyPyType<'_> {
186186fn evaluate ( src : String , evaluation_context : Option < & PyAny > ) -> PyResult < RustyCelType > {
187187 debug ! ( "Evaluating CEL expression: {}" , src) ;
188188
189- let program = Program :: compile ( & src)
190- . map_err ( |e| pyo3:: exceptions:: PyValueError :: new_err ( format ! ( "Failed to compile expression '{}': {}" , src, e) ) ) ?;
189+ let program = Program :: compile ( & src) . map_err ( |e| {
190+ PyValueError :: new_err ( format ! (
191+ "Failed to compile expression '{}': {}" ,
192+ src, e
193+ ) )
194+ } ) ?;
191195
192196 debug ! ( "Compiled program: {:?}" , program) ;
193197
@@ -205,20 +209,22 @@ fn evaluate(src: String, evaluation_context: Option<&PyAny>) -> PyResult<RustyCe
205209 // Clone variables and functions into our local Context
206210 ctx. variables = py_context_ref. variables . clone ( ) ;
207211 ctx. functions = py_context_ref. functions . clone ( ) ;
208-
209212 } else if let Ok ( py_dict) = evaluation_context. extract :: < & PyDict > ( ) {
210213 // User passed in a dict - let's process variables and functions from the dict
211214 ctx. update ( & py_dict) ?;
212215 } else {
213- return Err ( PyValueError :: new_err ( "evaluation_context must be a Context object or a dict" ) )
216+ return Err ( PyValueError :: new_err (
217+ "evaluation_context must be a Context object or a dict" ,
218+ ) ) ;
214219 } ;
215220
216-
217221 // Add any variables from the passed in Python context
218222 for ( name, value) in & ctx. variables {
219223 environment
220224 . add_variable ( name. clone ( ) , value. clone ( ) )
221- . map_err ( |e| PyValueError :: new_err ( format ! ( "Failed to add variable '{}': {}" , name, e) ) ) ?;
225+ . map_err ( |e| {
226+ PyValueError :: new_err ( format ! ( "Failed to add variable '{}': {}" , name, e) )
227+ } ) ?;
222228 }
223229
224230 // Add functions
@@ -244,11 +250,12 @@ fn evaluate(src: String, evaluation_context: Option<&PyAny>) -> PyResult<RustyCe
244250 let py_args = PyTuple :: new_bound ( py, py_args) ;
245251
246252 // Call the Python function
247- let py_result = py_function. call1 ( py, py_args)
248- . map_err ( |e| ExecutionError :: FunctionError {
253+ let py_result = py_function. call1 ( py, py_args) . map_err ( |e| {
254+ ExecutionError :: FunctionError {
249255 function : name. clone ( ) ,
250256 message : e. to_string ( ) ,
251- } ) ?;
257+ }
258+ } ) ?;
252259 // Convert the PyObject to &PyAny
253260 let py_result_ref = py_result. as_ref ( py) ;
254261
@@ -266,7 +273,6 @@ fn evaluate(src: String, evaluation_context: Option<&PyAny>) -> PyResult<RustyCe
266273 }
267274 }
268275
269-
270276 let result = program. execute ( & environment) ;
271277 match result {
272278 Err ( error) => {
0 commit comments