Skip to content

Commit 787bf15

Browse files
authored
Merge pull request #1137 from gianalarcon/update/rust-hello-world
Refactor(Rust/Hello-world): Refactor functions and update dependencies for improved codebase
2 parents 580ca11 + c3fc042 commit 787bf15

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

rust/hello_world/backend/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ path = "lib.rs"
1111

1212
[dependencies]
1313
candid = "0.10.10"
14-
ic-cdk = "0.16.0"
14+
ic-cdk = "0.18.3"
1515
ic-stable-structures = "0.6.7"

rust/hello_world/backend/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,13 @@ thread_local! {
2424
// This update method stores the greeting prefix in stable memory.
2525
#[ic_cdk::update]
2626
fn set_greeting(prefix: String) {
27-
GREETING.with_borrow_mut(|greeting| {
28-
greeting.set(prefix).unwrap();
29-
});
27+
GREETING.with_borrow_mut(|greeting| greeting.set(prefix).unwrap());
3028
}
3129

3230
// This query method returns the currently persisted greeting with the given name.
3331
#[ic_cdk::query]
3432
fn greet(name: String) -> String {
35-
let greeting = GREETING.with_borrow(|greeting| greeting.get().clone());
36-
format!("{greeting}{name}!")
33+
GREETING.with_borrow(|greeting| format!("{}{name}!", greeting.get()))
3734
}
3835

3936
// Export the interface for the smart contract.

0 commit comments

Comments
 (0)