Expand `Examples` in the `Sway Book`
Summary
The current examples section contains a few small... examples which do not demonstrate the common usage of the language but instead something a little closer to mini-contracts. The examples section should be easily searchable by a user to see how to perform common operations in Sway such as importing & dependency management, looping etc. and thus the current examples should be removed (and perhaps placed elsewhere).
This issue is meant to be an epic used to track the subtasks below.
Sections on how to:
- [ ] Log
- [ ] Get the
msg_sender(),msg_asset_id()&msg_amount() - [ ] Looping
- [ ] Mut vs immutable variables
- [ ] Implicit vs explicit returns
- [ ] Safety (
require()/revert()) - [ ]
impla comparison on a custom data structure e.g. theEqtrait - [ ] Match vs if let
- [ ] Token operations such as transferring to contract / output, minting / burning, checking contract balance
- [ ] Difference between the
Addressnamespace andContractId+Identityas the wrapper - [ ] Enums e.g.
Option&Result - [ ] Project management e.g. dependencies in Forc.toml vs splitting up files in the same project and using
depto import - [ ]
implABI methods - [ ] Storage manipulation
If there are additional important sections then feel free to edit / comment so that this description can be expanded.
Note that some of these may already exist in the Sway Book however they are in separate sections. We should unify all relevant examples into 1 section which the user can easily navigate rather than scattering them throughout the book.