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.
Standard library
README
file (FuelLabs#2803)
- Loading branch information
1 parent
f523c73
commit df9d5c0
Showing
1 changed file
with
17 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Sway Standard Library | ||
|
||
The Sway Standard Library is the foundation of portable Sway software, a set of minimal shared abstractions for the broader Sway ecosystem. It offers core types, like `Result<T, E>` and `Option<T>`, library-defined operations on language primitives, native asset management, blockchain contextual operations, access control, storage management, and support for types from other VMs, among many other things. | ||
|
||
## Usage | ||
|
||
The standard library is made implicitly available to all Forc projects created using `forc new`. In other words, it is not required to manually specify `std` as an explicit dependency. Forc will automagically use the version of `std` that matches its version. | ||
|
||
Importing items from the standard library can be done using the `use` keyword, just as importing items from any other Sway library. For example: | ||
|
||
```sway | ||
use std::storage::StorageMap; | ||
``` | ||
|
||
This imports the `StorageMap` type into the current namespace. | ||
|
||
The standard library comes with a "[prelude](https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/prelude.sw)" which is a list of things that Sway automatically imports into every Sway program. It's kept as small as possible, and is focused on things which are used in almost every single Sway program. |