Add very basic docs

This commit is contained in:
Sofia 2026-03-17 22:16:27 +02:00
parent f55f9be345
commit 80dfd74ee5
2 changed files with 28 additions and 1 deletions

View File

@ -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<vm::Value>) -> Result<Vec<vm::Value>, 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;

View File

@ -554,7 +554,7 @@ pub struct ClosureRunner {
}
#[derive(Clone, Debug)]
pub enum StackValue {
enum StackValue {
Value(Value),
Ref(Rc<RefCell<Value>>),
}