From cd6e6f853644caf5105e4d7e8feaa9821a43337e Mon Sep 17 00:00:00 2001 From: gianmalarcon Date: Thu, 1 May 2025 19:07:28 -0500 Subject: [PATCH 1/5] Refactor(Rust/Hello-world): Update fn greet() --- rust/hello_world/backend/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rust/hello_world/backend/lib.rs b/rust/hello_world/backend/lib.rs index 03460284a..ef14f9c21 100644 --- a/rust/hello_world/backend/lib.rs +++ b/rust/hello_world/backend/lib.rs @@ -32,8 +32,7 @@ fn set_greeting(prefix: String) { // This query method returns the currently persisted greeting with the given name. #[ic_cdk::query] fn greet(name: String) -> String { - let greeting = GREETING.with_borrow(|greeting| greeting.get().clone()); - format!("{greeting}{name}!") + GREETING.with_borrow(|greeting| format!("{}{name}!", greeting.get())) } // Export the interface for the smart contract. From c820d688dd95ae7f80eb615d15afc7e7a1324dec Mon Sep 17 00:00:00 2001 From: gianmalarcon Date: Thu, 1 May 2025 19:15:34 -0500 Subject: [PATCH 2/5] Refactor(Rust/Hello-world): Update fn set_greeting() --- rust/hello_world/backend/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rust/hello_world/backend/lib.rs b/rust/hello_world/backend/lib.rs index ef14f9c21..98fbad17d 100644 --- a/rust/hello_world/backend/lib.rs +++ b/rust/hello_world/backend/lib.rs @@ -24,9 +24,7 @@ thread_local! { // This update method stores the greeting prefix in stable memory. #[ic_cdk::update] fn set_greeting(prefix: String) { - GREETING.with_borrow_mut(|greeting| { - greeting.set(prefix).unwrap(); - }); + GREETING.with_borrow_mut(|greeting| greeting.set(prefix).unwrap()); } // This query method returns the currently persisted greeting with the given name. From 971101190d5c374b1b441338a98fb38fb3771293 Mon Sep 17 00:00:00 2001 From: gianmalarcon Date: Thu, 1 May 2025 19:27:48 -0500 Subject: [PATCH 3/5] Bump dependencie --- rust/hello_world/backend/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/hello_world/backend/Cargo.toml b/rust/hello_world/backend/Cargo.toml index e7c80c9a7..9b65581da 100644 --- a/rust/hello_world/backend/Cargo.toml +++ b/rust/hello_world/backend/Cargo.toml @@ -11,5 +11,5 @@ path = "lib.rs" [dependencies] candid = "0.10.10" -ic-cdk = "0.16.0" +ic-cdk = "0.18.0" ic-stable-structures = "0.6.7" From 82d4bdd8856ac34e924028921fb5d323943668b8 Mon Sep 17 00:00:00 2001 From: gianmalarcon Date: Thu, 1 May 2025 19:28:36 -0500 Subject: [PATCH 4/5] Refactor(Rust/Hello-world): Update path to declaration folder --- rust/hello_world/frontend/vite.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/hello_world/frontend/vite.config.js b/rust/hello_world/frontend/vite.config.js index 90e4d8c1d..37e39820e 100644 --- a/rust/hello_world/frontend/vite.config.js +++ b/rust/hello_world/frontend/vite.config.js @@ -20,7 +20,7 @@ export default defineConfig({ alias: [ { find: 'declarations', - replacement: fileURLToPath(new URL('../src/declarations', import.meta.url)) + replacement: fileURLToPath(new URL('../declarations', import.meta.url)) } ] }, From beb14b638cf6a351738f644bf1b55791ed08931d Mon Sep 17 00:00:00 2001 From: gianmalarcon Date: Thu, 1 May 2025 20:14:35 -0500 Subject: [PATCH 5/5] Revert update path --- rust/hello_world/frontend/vite.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/hello_world/frontend/vite.config.js b/rust/hello_world/frontend/vite.config.js index 37e39820e..90e4d8c1d 100644 --- a/rust/hello_world/frontend/vite.config.js +++ b/rust/hello_world/frontend/vite.config.js @@ -20,7 +20,7 @@ export default defineConfig({ alias: [ { find: 'declarations', - replacement: fileURLToPath(new URL('../declarations', import.meta.url)) + replacement: fileURLToPath(new URL('../src/declarations', import.meta.url)) } ] },