Internal Libraries
A library is internal to a project if it is in the same source src
directory as the other program files.
$ tree
.
├── Cargo.toml
├── Forc.toml
└── src
├── lib.sw
└── my_library.sw
To be able to use our library my_library.sw
in lib.sw
there are two steps to take:
- Bring our library into scope by using the
mod
keyword followed by the library name - Use the
use
keyword to selectively import various items from the library
library;
mod my_library;
use my_library::bar;
// `bar` from `my_library` is now available throughout the file