kw yield
Reserved keyword
The list of words: §1.4
Syntax
Primary = Literal | Path | "it" | "self" | "(" Expr { "," Expr } ")" | ListLit | MapLit
| StructLit | Lambda | Block | If | Match | For | While | Loop | Scope | Select | Query
| "spawn" ( Postfix | Block ) | "await" Unary | "atomic" [ "(" Args ")" ] Block
| "return" [ Expr ] | "fail" Expr | "yield" Expr | "respond" Expr | "break" [ Label ] [ Expr ]
| "continue" [ Label ] | "emit" Path "(" Expr ")" | "unsafe" Block | "blocking" Block
| "comptime" Block | "." Ident [ "(" [ Args ] ")" ] ;Grammar: App. A
Defined in
- 10.3 Streams — The type is stream<T, E = never>.
- 5.8 Other expressions — defer e — executes e on leaving the block (including on fail, return, cancellation), in the reverse order of declaration.
- 18.2 Assertions and fixtures — assert expr is executed in all profiles, including prod (profiles switch off only contracts, §6.7, and the output of dbg, §2.2); on failure
- 1.4 Keywords — Reserved (cannot be used as names)
Examples
fixture tempDb() -> Db {
let d = Db.open("sqlite::memory:")
yield d // the test runs here
d.close()
}
test "insert" with tempDb as db { db.insert(order) }— 18.2 Assertions and fixtures
Related diagnostics
yield-outside-stream, fixture-yield