Rust
Embedding Stof in Rust.
Because Stof is written in Rust, there is a lot of support for using Stof with Rust.
To add Stof to your Rust project, use cargo:
cargo add stof
The main interfaces to Stof are the document (SDoc) and graph (SGraph). If you're working primarily with the Stof language interface (like in the rest of these documents), you won't need to interact with the graph. However, if you need deeper control, the graph organizes and stores the data.
Hello, World!
The classic first program. A document can be constructed from a string, file, or binary (Vec<u8>) (each with a format specifier). In this case, we are constructing a document from a Stof string.
use stof::SDoc;
fn main() {
let mut doc = SDoc::src(r#"
#[main]
fn main() {
pln('hello, world!');
}
"#, "stof").unwrap();
let _ = doc.run(None);
}
> cargo run
hello, world!
Last updated
Was this helpful?