Skip to content

Commit

Permalink
Improve stdlib section in book. (FuelLabs#1731)
Browse files Browse the repository at this point in the history
  • Loading branch information
adlerjohn authored May 27, 2022
1 parent fa5da06 commit b871452
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions docs/src/introduction/standard_library.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ Similar to Rust, Sway comes with its own 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.

The standard library is made implicitly available to all Forc projects created using [`forc init`](../forc/commands/forc_init.md). Importing items from the standard library can be done using the `use` keyword. Example:
The entire Sway standard library is a Forc project called `std`, and is available directly here: <https://github.com/FuelLabs/sway/tree/master/sway-lib-std> (navigate to the appropriate tagged release if the latest `master` is not compatible).

## Using the Standard Library

The standard library is made implicitly available to all Forc projects created using [`forc init`](../forc/commands/forc_init.md). 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 Sway project. For example:

```sway
use std::address::Address;
```

## Using the Standard Library

Aside from the references to the standard library accross this book, you may also read the `std` library project directly [here](https://github.com/FuelLabs/sway/tree/master/sway-lib-std).

This imports the `Address` type into the current namespace.

0 comments on commit b871452

Please sign in to comment.