Declare statements take the form
declare invariant
They can be applied to spaces, classes, one-of's / one-value-of's / many-of's, and within functions.
Scope Legend
S = Space C = Class O = One-of F = Function
Full Declare List
| Member | Description | Scope |
|---|---|---|
| declare abstract | Defines a class, pick, or bundle as must inherit. | C |
| declare sealed | Defines the class as not inheritable (sealed) | C |
| declare unit | Marks a numeric-backed primitive class as usable through unit suffix syntax. | C |
| declare union | Declares a type as a structural union | C |
| declare pack | Declares a type as a bit-packed class, primitive class, or array | C |
| declare align8 | Aligns the members of a type to 8-bit alignment | C |
| declare align16 | Aligns the members of a type to 16-bit alignment | C |
| declare align32 | Aligns the members of a type to 32-bit alignment | C |
| declare align64 | Aligns the members of a type to 64-bit alignment | C |
| declare align128 | Aligns the members of a type to 128-bit alignment | C |
| declare bigEndian | Used to set the bit-order of the members of a type as big endian. | SC |
| declare pureFunctional | Requires that the function be a pure function | SCF |
| declare totalFunctional | Requires that the function be a total function | SCF |
| declare decidable | Requires that the function be computationally decidable | SCF |
| declare gpu | Requires that the code within the scope be able to be GPU-offloadable | SCF |
| declare webAssembly | Requires that the code within the scope be compiled to web assembly. | SCF |
| declare inline | Enforces the function to be inlined into it's call site. | F |
| declare noNetwork | Prevents network access within a scope. | SCF |
| declare noDisk | Prevents disk access within a scope. | SCF |
| declare noAllocation | Prevents memory allocations within a scope. | SCF |
| declare noRecursiveTypeDefinitions | Relevant? | S |
| declare noReferenceCounting | Prevents reference counting behavior within a scope. | SC |
| declare noReferenceCountingDeallocationQueue | Disables the reference counting deallocation queue within a scope. | SC |
| declare noReferences | Placed within a class or type to disallow reference types from being defined within the structure. | SC |
| declare noAutomaticNumberConversion | Reports potentially lossy automatic number conversions. An explicit conversion satisfies the declaration; compilation recovery preserves the ordinary automatic conversion. | SCF |
| declare noArithmeticOverflow | Causes the debugging interpreter to report fixed-width integer and fixed-decimal overflow and oversized shifts. It does not change the wrapped result or compiled output. | SCF |
| declare noDivisionByZero | Causes the debugging interpreter to report division or remainder by zero for every numeric family. It does not change the result or compiled output. | SCF |
| declare noType | Defines a reference class or primitive class with no type information. Type checks fail on this and it's for memory-sensitive code only. | SC |
| declare noWorkers | Specifies that no code within the scope is single-threaded only. Mostly useful for lowering to targets where multi-threading isn't supported (like WASM). This may actually just cause multi-threaded code to behave like single threaded code. Or it might change the display of the code in the editor. | SC |
| declare markupFactory | Declares the function that markup literals call behind the scenes in the given scope. | SC |
| declare markdownFrontMatterFactory | ? | SC |
| declare frontMatter | Declares a type as being viable for front-matter matching. | C |
| declare noEcmaStandardLibrary | Prevents the ECMA-262 built-ins from being included in the compilation output. | S |
| declare noRustStandardLibrary | Prevents the Rust standard library from being included in the output. | S |
| declare external | Preserves the functions name for FFI compatibility in Rust outputs. Has the effect of no_mangle in the emitted Rust. | SCF |
| declare reversible | Declare a operator overload function as compiler-reversible (injective) | F |
| declare worker W | Defines the thread on which code in a given scope executes | SCF |
| declare size [primitive] | Fallback for rust's #[repr(primitive)]. Used on one-of's |
O |
| declare enableNanProtection | Causes the interpreter to break whenever a nan value is generated | SCF |
| declare import P [version V] [features F...] | Establishes inherited wrapper-package features and version policy without creating a module binding. | S |
Import Policy
declare import establishes package policy in a space without introducing a module binding:
declare import Sqlx version 1.2.3 features postgres mysql sqlite
The version and features clauses are optional, and their ordering as described above is required.
The declaration is visible in its immediate space and child spaces. A matching import inherits omitted features and versions from the nearest visible declaration. Options written directly on an import take precedence.
Cargo features requested for the same package version are unioned across the complete dependency graph, even when their declarations appear in different lexical spaces. A declare import does not create a local module binding.