forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update
std::storage::get
and std::storage::StorageMap::get
to ret…
…urn an `Option` (FuelLabs#3862) API change: Previous: ```rust pub fn get<T>(key: b256) -> T; pub fn get(self, key: K) -> V; ``` Now: ```rust pub fn get<T>(key: b256) -> Option<T>; pub fn get(self, key: K) -> Option<V>; ``` `Option::None` indicates that the storage slot requested in not available. - Updated all storage intrinsics to return a `bool` except for `__state_load_word` because it already returns the value loaded. The `bool` returned represents the previous state of the storage slots as described in the specs. I was not able to update `__state_load_word` to return both the value loaded and the `bool` unfortunately because I hit various hiccups along the way, particularly in IR/codegen. - Updated `get` and `StorageMap::get` in the standard library to return an `Option` based on the Boolean mentioned above. In the copy type case, I had to use `asm` blocks instead of `__state_load_word` until we're able to return a struct from an intrinsic. - I did not update `store` and `StorageMap::insert` to return an `Option`, for now, because that would involve an extra storage read to return the previous value, if available. We can think about whether this is worth it at some point. - I added `unwrap` and `unwrap_or` where it makes sense in `StoargeVec`. - Update various docs, examples, and tests. Closes FuelLabs#3318 I will open separate issues for updating `__state_load_word` and thinking about making `store` and `insert` also return an `Option`.
- Loading branch information
1 parent
a0ef103
commit 0a3beae
Showing
28 changed files
with
586 additions
and
310 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
docs/reference/src/documentation/misc/workarounds/missing-features.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Missing Features |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.