From eb083c29727658fd466d264c557d6a15bbcccf8f Mon Sep 17 00:00:00 2001 From: Jeff Date: Mon, 2 Dec 2024 02:46:04 -0500 Subject: [PATCH] Add some more docs --- dust-lang/src/disassembler.rs | 2 ++ dust-lang/src/lib.rs | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/dust-lang/src/disassembler.rs b/dust-lang/src/disassembler.rs index a4651e4..664bf86 100644 --- a/dust-lang/src/disassembler.rs +++ b/dust-lang/src/disassembler.rs @@ -8,6 +8,8 @@ //! The disassembler can be customized with the 'styled' option, which will apply ANSI color codes //! to the output. //! +//! If the 'source' option is set, the disassembler will include the source code in the output. +//! //! # Output //! //! The output of [Disassembler::disassemble] is a string that can be printed to the console or diff --git a/dust-lang/src/lib.rs b/dust-lang/src/lib.rs index ef48525..4bea669 100644 --- a/dust-lang/src/lib.rs +++ b/dust-lang/src/lib.rs @@ -1,4 +1,32 @@ //! The Dust programming language library. +//! +//! # Running Programs +//! +//! Dust is easy to embed in another application. The `run` function can be used to run Dust code +//! and get the program's result in a single call. +//! +//! If a program returns a value, it does so with a ConcreteValue. Dust's concrete values are simple +//! and flexible, they are wrappers for familiar Rust types like String, i64 and Vec. +//! +//! If an error occurs, it is returned as a DustError. This error can be used to create a report +//! with source annotations, which should be printed to the user. +//! +//! ## Examples +//! +//! ```rust +//! # use dust_lang::{run, ConcreteValue}; +//! let result = run("21 * 2").unwrap(); +//! +//! assert_eq!(result, Some(ConcreteValue::Integer(42))); +//! ``` +//! +//! ```rust +//! # use dust_lang::{run, DustError}; +//! let error = run("21 + wut").unwrap_err(); +//! let report = error.report(); +//! +//! println!("{}", report); +//! ``` pub mod chunk; pub mod compiler;