Skip to content

Commit

Permalink
Doc storage read unwrap_or clarification. (FuelLabs#4736)
Browse files Browse the repository at this point in the history
## Description
Document clarification around ensuring .unwrap_or(0) is used for storage
read examples.

---------

Co-authored-by: Joshua Batty <[email protected]>
  • Loading branch information
SilentCicero and JoshuaBatty authored Jul 4, 2023
1 parent 696f14c commit 461f679
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions examples/storage_variables/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ impl StorageExample for Contract {
#[storage(read)]
fn get_something() -> (u64, u64, b256, bool) {
(
storage.var1.x.read(),
storage.var1.y.read(),
storage.var2.w.read(),
storage.var2.z.read(),
storage.var1.x.try_read().unwrap_or(0),
storage.var1.y.try_read().unwrap_or(0),
storage.var2.w.try_read().unwrap_or(0x0000000000000000000000000000000000000000000000000000000000000000),
storage.var2.z.try_read().unwrap_or(false),
)
}
// ANCHOR_END: storage_read
Expand Down

0 comments on commit 461f679

Please sign in to comment.