Add very basic docs
This commit is contained in:
parent
f55f9be345
commit
80dfd74ee5
27
src/lib.rs
27
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<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 std::{fmt::Debug, path::PathBuf};
|
||||||
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user