A small multi-file program
This final program has no new syntax. One module owns the domain types and lookup; the entry module waits for data, calls the fallible operation, and matches its result.
Edit the requested title or the collection. Both files travel in the same bounded request, exactly as they would in a local project.
use catalog.{Book, Query, find}
async fn load() -> [Book] {
await sleep(1)
[
Book { title: "moon", tags: ["language", "tour"] },
Book { title: "Stars", tags: ["space"] },
]
}
async fn main() {
let books = await load()
match find(books, .Title("moon")) {
ok(book) => println("${book.title}: ${book.tags.join(",")}"),
err(error) => println("${error.name}: ${error.message}"),
}
}
Examples use the moon toolchain version shown beside each result.
Output & diagnostics
Expected: moon: language,tour
Ctrl/⌘+Enter runs the current lesson.