## Overview
Closes#3217, migrates the reentrancy library to Sway-libs.
> Notice: Awaiting merge and version bump from Sway-libs ([relevant pull
request](https://github.com/FuelLabs/sway-libs/pull/70)).
## Changes
- remove reentrancy library
- remove reentrancy tests
- modifies documentation to point to new reentrancy guard url
- modifies imports of `std::reentrancy::` to `sway_libs::reentrancy`
---------
Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>
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 https://github.com/FuelLabs/sway/issues/3318
I will open separate issues for updating `__state_load_word` and
thinking about making `store` and `insert` also return an `Option`.
## Summary
More information can be found in #2443 .
Notes for PR:
- The review is meant to take place using `mdbook` so check out the main
`README.md` to see how to run it in the browser
- This book is incomplete however there are a lot of pages so the idea
is to PR this into the repo soon so that subsequent reviews are smaller
- No CI added until the book is ready to replace the current book
- Ideally reviews are split between multiple people because there is a
lot of content
Closes#2443
## Pages Reviewed
@matt-user : Program Types -> Functions, Misc
Co-authored-by: Bikem <bengisuozaydin@gmail.com>
Co-authored-by: Matt <54373384+matt-user@users.noreply.github.com>
Co-authored-by: Cameron Carstens <54727135+bitzoic@users.noreply.github.com>
Co-authored-by: bing <bingcicle@proton.me>
Co-authored-by: Mitch Martin <111294749+mitch-fuel@users.noreply.github.com>
Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>
Co-authored-by: Luiz Felipe Bolsoni Gomes <8636507+LuizAsFight@users.noreply.github.com>
Co-authored-by: K1-R1 <77465250+K1-R1@users.noreply.github.com>
Co-authored-by: Alex Hansen <alex@alex-hansen.com>