summaryrefslogtreecommitdiff
path: root/src/table.rs
diff options
context:
space:
mode:
authorAlex Orlenko <zxteam@protonmail.com>2019-10-17 16:59:33 +0100
committerAlex Orlenko <zxteam@protonmail.com>2019-11-04 22:23:15 +0000
commit6874c2e004f9fa92add76f1ddb4076bf80fd90ad (patch)
tree89858452730e46e5c4f6e7b5dfeb309bd87fe788 /src/table.rs
parent4a802c13738f2f7de3d2d664a33b7e7c6bf8f573 (diff)
downloadmlua-6874c2e004f9fa92add76f1ddb4076bf80fd90ad.zip
Fix examples and docs
Diffstat (limited to 'src/table.rs')
-rw-r--r--src/table.rs24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/table.rs b/src/table.rs
index 7a5be54..0c3e143 100644
--- a/src/table.rs
+++ b/src/table.rs
@@ -27,12 +27,12 @@ impl<'lua> Table<'lua> {
/// ```
/// # use mlua::{Lua, Result};
/// # fn main() -> Result<()> {
- /// let lua = Lua::new();
+ /// # let lua = Lua::new();
/// let globals = lua.globals();
///
/// globals.set("assertions", cfg!(debug_assertions))?;
///
- /// lua.exec::<_, ()>(r#"
+ /// lua.load(r#"
/// if assertions == true then
/// -- ...
/// elseif assertions == false then
@@ -40,7 +40,7 @@ impl<'lua> Table<'lua> {
/// else
/// error("assertions neither on nor off?")
/// end
- /// "#, None)?;
+ /// "#).exec()?;
/// # Ok(())
/// # }
/// ```
@@ -80,7 +80,7 @@ impl<'lua> Table<'lua> {
/// ```
/// # use mlua::{Lua, Result};
/// # fn main() -> Result<()> {
- /// let lua = Lua::new();
+ /// # let lua = Lua::new();
/// let globals = lua.globals();
///
/// let version: String = globals.get("_VERSION")?;
@@ -134,19 +134,21 @@ impl<'lua> Table<'lua> {
}
/// Gets the function associated to `key` from the table and executes it,
- /// passing the table as the first argument.
+ /// passing the table itself as the first argument.
///
/// # Examples
///
/// Execute the table method with name "concat":
///
/// ```
- /// # use mlua::{Function, Lua, Result};
+ /// # use mlua::{Lua, Result, Table};
/// # fn main() -> Result<()> {
/// # let lua = Lua::new();
- /// # let table = lua.create_table();
- /// // Lua: table:concat("param1", "param2")
- /// table.call("concat", ("param1", "param2"))?;
+ /// # let object = lua.create_table()?;
+ /// # let concat = lua.create_function(|_, (_, a, b): (Table, String, String)| Ok(a + &b))?;
+ /// # object.set("concat", concat)?;
+ /// // simiar to: object:concat("param1", "param2")
+ /// object.call("concat", ("param1", "param2"))?;
/// # Ok(())
/// # }
/// ```
@@ -294,7 +296,7 @@ impl<'lua> Table<'lua> {
/// ```
/// # use mlua::{Lua, Result, Value};
/// # fn main() -> Result<()> {
- /// let lua = Lua::new();
+ /// # let lua = Lua::new();
/// let globals = lua.globals();
///
/// for pair in globals.pairs::<Value, Value>() {
@@ -336,7 +338,7 @@ impl<'lua> Table<'lua> {
/// ```
/// # use mlua::{Lua, Result, Table};
/// # fn main() -> Result<()> {
- /// let lua = Lua::new();
+ /// # let lua = Lua::new();
/// let my_table: Table = lua.load(r#"
/// {
/// [1] = 4,