diff --git a/docs/book/src/SUMMARY.md b/docs/book/src/SUMMARY.md index 262437ea2cc..8b5ce8382e1 100644 --- a/docs/book/src/SUMMARY.md +++ b/docs/book/src/SUMMARY.md @@ -73,6 +73,10 @@ - [Behavior Considered Undefined](./reference/undefined_behavior.md) - [Differences From Solidity](./reference/solidity_differences.md) - [Differences From Rust](./reference/rust_differences.md) + - [Storage](./reference/storage/storage.md) + - [Initialization](./reference/storage/init.md) + - [Reading & Writing](./reference/storage/read-write.md) + - [Libraries](./reference/storage/libraries/index.md) - [Contributing To Sway](./reference/contributing_to_sway.md) - [Keywords](./reference/keywords.md) - [Forc Reference](./forc/index.md) diff --git a/docs/book/src/reference/known_issues_and_workarounds.md b/docs/book/src/reference/known_issues_and_workarounds.md index d60c5d23de3..71c4d362943 100644 --- a/docs/book/src/reference/known_issues_and_workarounds.md +++ b/docs/book/src/reference/known_issues_and_workarounds.md @@ -8,6 +8,35 @@ * [#1182](https://github.com/FuelLabs/sway/issues/1182) Arrays in a `storage` block are not yet supported. See the [Manual Storage Management](../advanced/advanced_storage.md#manual-storage-management) section for details on how to use `store` and `get` from the standard library to manage storage slots directly. Note, however, that `StorageMap` _does_ support arbitrary types for `K` and `V` without any limitations. + +## Importing + +In [external libraries](../../language/program-types/libraries/external.md) we have looked at how a library can be imported into a project so that code can be reused. + +When it comes to importing only external libraries can be imported through the `Forc.toml` file; any other type of program will result in an error. + +This means that the following projects cannot be imported: + +- [contracts](../../language/program-types/contract.md) +- [internal libraries](../../language/program-types/libraries/internal.md) +- [scripts](../../language/program-types/script.md) +- [predicates](../../language/program-types/predicate.md) + +While contracts cannot be imported, a workaround is to move the contract's `abi` declaration into an [external library](../../language/program-types/libraries/external.md) and import that library anywhere the ABI is needed. + +## Pattern Matching + +### Nested Match Expressions + +In [nested match expressions](../../language/control-flow/match/complex/nested-expression.md) we nest a `match` expression by embedding it inside the `{}` brackets on the right side of the arrow `=>`. + +Match expressions cannot be used as a pattern, the left side of the arrow `=>`. + +### Constants + +When matching on [constants](../../language/control-flow/match/complex/constant.md) we specify that a constant must be used in order to match on a variable. Dynamic values, such as an argument to a function, cannot be matched upon because it will be treated as a [`catch_all`](../../language/control-flow/match/single-line.md) case and thus any subsequent patterns will not be checked. + + ## General * No compiler optimization passes have been implemented yet, therefore bytecode will be more expensive and larger than it would be in production. Note that eventually the optimizer will support zero-cost abstractions, avoiding the need for developers to go down to inline assembly to produce optimal code. diff --git a/docs/book/src/reference/storage.md b/docs/book/src/reference/storage.md new file mode 100644 index 00000000000..bbb6cea2d87 --- /dev/null +++ b/docs/book/src/reference/storage.md @@ -0,0 +1,11 @@ +# Storage + +A [smart contract](../../language/program-types/contract.md) is able to perform computation and store & manipulate data over time. + +In the following sections we'll take a look at how Sway handles `storage` through: + +- [Storage Initialization](init.md): How to declare a `storage` block +- [Reading & Writing](read-write.md): How to read from and write to storage +- [Libraries](libraries/index.md): Additional functionality provided by the [storage library](https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/storage.sw) +- [Namespaces](namespace.md): How to use `storage` namespaces +- [In keyword](in-keyword.md): How to override storage variable position