If topaz check rejects a familiar spelling, find its Topaz replacement below. For features without a direct replacement, choose an alternative that fits the result you need.
Run the supported forms
Install Topaz through First Program, then save this as forbidden-deferred.tpz.
let mut count = 0
let values: Array<int> = [1, 2]
let transform: (int) -> int = value => value + 1
match values {
case [head, ..tail] => {
count = transform(head) + tail.length
}
case [] => {
count = 0
}
}
print("{count}")Check and run it from the folder containing the file.
topaz check forbidden-deferred.tpz
topaz run forbidden-deferred.tpzThe check succeeds, and the program prints the following result.
3let mut allows count to change. The pattern binds head to 1 and tail to [2]. transform(head) returns 2, and adding the tail length gives 3. The type (int) -> int describes the function stored in transform.
Replace unsupported spellings
| If you tried | Use instead |
|---|---|
mut let count = 0 | let mut count = 0 |
count++ or count-- | count = count + 1 or count = count - 1 |
[T] as a type | Array<T> |
function(T) -> U as a type | (T) -> U |
args: ...T | ...args: T |
[head, ...tail] | [head, ..tail] |
An anonymous function (...) { ... } | A lambda such as value => value + 1 |
Backticks or ${value} | Double quotes and {value} interpolation |
String indexing or .length | text.scalars() followed by Array operations |
In forbidden-deferred.tpz, replacing let mut with mut let makes the check fail. Restore let mut on the first line, then check and run the file again.
For imports, name the members you need. Mark exported declarations with export where they are declared. Modules & Visibility shows the forms. use, string or template module paths, export lists, wildcard exports, re-exports, and export-site renaming are unsupported.
Choose an alternative for an unsupported feature
The features below are unavailable in the current language. These alternatives solve the stated tasks and may require changing the program's structure.
| Task | Unsupported feature | Current choice |
|---|---|---|
| Inspect text | Grapheme-cluster APIs and direct string slices | Use scalars() when Unicode scalar boundaries fit the task |
| Build text or structured templates | HTML and custom template tags | Use strings or the built-in p, r, sh, sql tags for their stated purposes |
| Express generic requirements | Higher-rank constraints and general dynamic protocol dispatch | Use the supported named-function bounds in Functions & Generics |
| Describe recursive data | Recursive type aliases | Use supported enum declarations from Records & Nominal Data |
| Share declarations between modules | Package re-exports | Import members from the module that declares them |
| Expand elements | General iterable spread | Use Array spread in its supported positions, or iterate explicitly |
| Run work concurrently | async and await | Use concurrent when collecting named results with a timeout fits the task |
| Close resources | Asynchronous cleanup | Use synchronous defer or supported using forms |
| Handle an expected failure | Fault catching and panic, throw, catch | Return a Result for recoverable errors |
| Read an optional field in a pipeline | Optional-property pipe shorthand | Write an explicit expression using ?. |
A runtime fault stops execution. Changing its syntax cannot make it a recoverable Result. Prevent the invalid operation or use an API that returns an ordinary error value. See Null, Option, Result & Faults.
Rust forms such as &self, &mut self, Vec<T>, and use crate:: are not Topaz syntax. Use module-level impl Name, built-in collection types, explicit imports, and Topaz record updates.
Find examples in Syntax at a Glance. For operator corrections, continue with Operators & Expressions.