From 7600ecfbef267eb212b7d39cdd597757b44c90fe Mon Sep 17 00:00:00 2001 From: Ian Rumac Date: Tue, 22 Oct 2024 15:48:26 +0200 Subject: [PATCH 1/3] Fix issues with type inference --- src/lib.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 93b0115..fd075c0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -61,7 +61,7 @@ pub fn evaluate_ast_with_context(definition: String, host: Arc) let data = match data { Ok(data) => data, Err(_) => { - let e = Err("Invalid execution context JSON".to_string()); + let e : Result<_, String> = Err::("Invalid execution context JSON".to_string()); return serde_json::to_string(&e).unwrap() } }; @@ -87,7 +87,7 @@ pub fn evaluate_ast(ast: String) -> String { let data : JSONExpression = match data { Ok(data) => data, Err(_) => { - let e = Err("Invalid definition for AST Execution".to_string()); + let e : Result<_, String> = Err::("Invalid definition for AST Execution".to_string()); return serde_json::to_string(&e).unwrap() } }; @@ -110,13 +110,7 @@ pub fn evaluate_with_context(definition: String, host: Arc) -> let data: ExecutionContext = match data { Ok(data) => data, Err(_) => { - let e = Err("Invalid execution context JSON".to_string()); - return serde_json::to_string(&e).unwrap() - } - }; - let data = match data { - Ok(data) => data, - Err(e) => { + let e : Result = Err("Invalid execution context JSON".to_string()); return serde_json::to_string(&e).unwrap() } }; From c06f803e4d1de38367e49a15e14e5b439e43791d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20To=CC=88r?= <3296904+yusuftor@users.noreply.github.com> Date: Tue, 22 Oct 2024 15:52:50 +0200 Subject: [PATCH 2/3] Update changelog and version --- CHANGELOG.md | 6 ++++++ Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de79c9d..34784a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # CHANGELOG +## 0.1.12 + +## Fixes + +- Adds Result types to fix issues when building for iOS. + ## 0.1.11 ## Enhancements diff --git a/Cargo.toml b/Cargo.toml index e60c074..0b07978 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cel-eval" -version = "0.1.11" +version = "0.1.12" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.htmlž From 8be57d160446bb7b7421899900a50860b86130d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20To=CC=88r?= <3296904+yusuftor@users.noreply.github.com> Date: Tue, 22 Oct 2024 15:53:21 +0200 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34784a3..9f2bf02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,32 +2,32 @@ ## 0.1.12 -## Fixes +### Fixes - Adds Result types to fix issues when building for iOS. ## 0.1.11 -## Enhancements +### Enhancements - Adds new Android target - Ensures JSON deserialization is done in a safe manner ## 0.1.10 -## Enhancements +### Enhancements - Updates github workflow for the renaming of the iOS repository. ## 0.1.9 -## Enhancements +### Enhancements - Added returning of a JSON encoded `Result` from the exposed methods instead of relying on panics. Example JSON: - Error: `{"Err":"No such key: should_display"}` - Ok: `{"Ok":{"type":"bool","value":true}}` -## Fixes +### Fixes - Fixed a bug where getting properties from `device` would panic when `device` functions were defined