The following list contains keywords that are reserved for current or future use by the Sway language. As such, they cannot be used as identifiers. Identifiers are names of functions, variables, parameters, modules, constants, attributes, types or traits, etc.
The following is an alphabetically sorted list of keywords currently in use, with their functionality shortly described.
as
- rename items in use
statements, e.g., use type::type_name as alias_name;
abi
- define a smart contract ABI in a syntactically similar way to traits asm
- define an assembly block break
- exit a loop immediately configurable
- define configurable constants const
- define constant continue
- continue to the next loop iteration contract
- define contract program type else
- used in conjunction with if
conditions for control flow constructs enum
- define an enum false
- Boolean false literal for
- loop based on iterators fn
- define a function if
- branch based on the result of a conditional expression impl
- implement inherent or trait functionality let
- bind a variable library
- define library program type match
- exhaustively match a value to patterns mod
- define a module mut
- denote mutability pub
- denote public visibility predicate
- define predicate program type ref
- bind by reference return
- return early from a function script
- define script program type Self
- a type alias for the type we are defining or implementing self
- method call target storage
- define a storage declaration str
- string slice struct
- define a structure trait
- define a trait true
- Boolean true literal type
- define a type alias or associated type use
- bring symbols into scope where
- specifies trait constraints for generic type arguments while
- loop conditionally based on the result of an expression abstract
async
await
become
box
do
dyn
extern
for
in
loop
macro
move
override
priv
static
super
try
typeof
unsafe
unsized
virtual
yield