diff --git a/examples/README.md b/examples/README.md index 51a4a1d2..182b46a5 100644 --- a/examples/README.md +++ b/examples/README.md @@ -7,6 +7,7 @@ Standard Examples | Example | Description | | --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | | [`arrays_and_structs`](arrays_and_structs.rs) | shows how to register a Rust type and using it with arrays | +| [`callback`](callback.rs) | shows how to store a Rhai closure and call it later within Rust | | [`custom_types_and_methods`](custom_types_and_methods.rs) | shows how to register a Rust type and methods/getters/setters for it | | [`hello`](hello.rs) | simple example that evaluates an expression and prints the result | | [`reuse_scope`](reuse_scope.rs) | evaluates two pieces of code in separate runs, but using a common `Scope` | diff --git a/examples/arrays_and_structs.rs b/examples/arrays_and_structs.rs index 472c9979..1cfeac47 100644 --- a/examples/arrays_and_structs.rs +++ b/examples/arrays_and_structs.rs @@ -1,3 +1,5 @@ +//! An example showing how to register a Rust type and use it with arrays. + use rhai::{Engine, EvalAltResult}; #[cfg(not(feature = "no_index"))] diff --git a/examples/custom_types_and_methods.rs b/examples/custom_types_and_methods.rs index 581e0ff6..e8261a73 100644 --- a/examples/custom_types_and_methods.rs +++ b/examples/custom_types_and_methods.rs @@ -1,3 +1,5 @@ +//! An example showing how to register a Rust type and methods/getters/setters for it. + use rhai::{Engine, EvalAltResult}; #[cfg(not(feature = "no_object"))] diff --git a/examples/hello.rs b/examples/hello.rs index c35b3013..b85b06da 100644 --- a/examples/hello.rs +++ b/examples/hello.rs @@ -1,3 +1,5 @@ +//! A simple example that evaluates an expression and prints the result. + use rhai::{Engine, EvalAltResult}; fn main() -> Result<(), Box> { diff --git a/examples/reuse_scope.rs b/examples/reuse_scope.rs index 240d48c4..3bfa6bf3 100644 --- a/examples/reuse_scope.rs +++ b/examples/reuse_scope.rs @@ -1,3 +1,5 @@ +//! An example that evaluates two pieces of code in separate runs, but using a common `Scope`. + use rhai::{Engine, EvalAltResult, Scope}; fn main() -> Result<(), Box> { diff --git a/examples/serde.rs b/examples/serde.rs index f5554889..625bb5f6 100644 --- a/examples/serde.rs +++ b/examples/serde.rs @@ -1,3 +1,5 @@ +//! An example to serialize and deserialize Rust types. + #[cfg(any(not(feature = "serde"), feature = "no_object"))] fn main() { println!("This example requires the 'serde' feature to run."); diff --git a/examples/simple_fn.rs b/examples/simple_fn.rs index 814e9ccf..06b28c53 100644 --- a/examples/simple_fn.rs +++ b/examples/simple_fn.rs @@ -1,3 +1,5 @@ +//! An example showing how to register a simple Rust function. + use rhai::{Engine, EvalAltResult}; fn add(x: i64, y: i64) -> i64 { diff --git a/examples/strings.rs b/examples/strings.rs index a0997da2..e3fac382 100644 --- a/examples/strings.rs +++ b/examples/strings.rs @@ -1,5 +1,6 @@ -///! This example registers a variety of functions that operate on strings. -///! Remember to use `ImmutableString` or `&str` instead of `String` as parameters. +//! An example that registers a variety of functions that operate on strings. +//! Remember to use `ImmutableString` or `&str` instead of `String` as parameters. + use rhai::{Engine, EvalAltResult, ImmutableString, Scope}; use std::io::{stdin, stdout, Write}; @@ -12,6 +13,7 @@ fn trim_string(s: &mut ImmutableString) { /// Notice this is different from the built-in Rhai 'len' function for strings /// which counts the actual number of Unicode _characters_ in a string. +/// /// This version simply counts the number of _bytes_ in the UTF-8 representation. /// /// This version uses `&str`. diff --git a/examples/threading.rs b/examples/threading.rs index d28f62d7..64cd04dc 100644 --- a/examples/threading.rs +++ b/examples/threading.rs @@ -1,3 +1,6 @@ +//! An advanced example showing how to communicate with an `Engine` running in a separate thread via +//! an MPSC channel. + use rhai::Engine; #[cfg(feature = "sync")]