From 80dfd74ee540a9196d92966d410555d37f5ff561 Mon Sep 17 00:00:00 2001 From: Sofia Date: Tue, 17 Mar 2026 22:16:27 +0200 Subject: [PATCH] Add very basic docs --- src/lib.rs | 27 +++++++++++++++++++++++++++ src/vm.rs | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 2f6dc4a..ade9cc6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,30 @@ +//! Usage example: +//! ```rust +//! use ferrite_lua::{compile, vm}; +//! +//! #[derive(Debug, PartialEq, Eq)] +//! pub struct Print; +//! impl vm::RustFunction for Print { +//! fn execute(&self, parameters: Vec) -> Result, vm::RuntimeError> { +//! println!("{:?}", parameters); +//! Ok(Vec::new()) +//! } +//! +//! fn as_indexable(&self) -> String { +//! "std::print".to_owned() +//! } +//! } +//! +//! let compilation_unit = compile("print(\"hello\")", None).unwrap(); +//! +//! let mut vm = vm::VirtualMachine::default(); +//! vm.set_global("print".into(), Print.into()); +//! +//! let mut runner = compilation_unit.with_virtual_machine(&mut vm).execute(); +//! +//! while runner.next().unwrap().is_none() { } +//! ``` + use std::{fmt::Debug, path::PathBuf}; use thiserror::Error; diff --git a/src/vm.rs b/src/vm.rs index ca0e558..ccbc6d9 100644 --- a/src/vm.rs +++ b/src/vm.rs @@ -554,7 +554,7 @@ pub struct ClosureRunner { } #[derive(Clone, Debug)] -pub enum StackValue { +enum StackValue { Value(Value), Ref(Rc>), }