summaryrefslogtreecommitdiff
path: root/src/thread.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/thread.rs
parent4a802c13738f2f7de3d2d664a33b7e7c6bf8f573 (diff)
downloadmlua-6874c2e004f9fa92add76f1ddb4076bf80fd90ad.zip
Fix examples and docs
Diffstat (limited to 'src/thread.rs')
-rw-r--r--src/thread.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/thread.rs b/src/thread.rs
index 52ec66a..97b0362 100644
--- a/src/thread.rs
+++ b/src/thread.rs
@@ -46,26 +46,27 @@ impl<'lua> Thread<'lua> {
/// # Examples
///
/// ```
- /// # use mlua::{Lua, Thread, Error};
+ /// # use mlua::{Error, Lua, Result, Thread};
/// # fn main() -> Result<()> {
- /// let lua = Lua::new();
- /// let thread: Thread = lua.eval(r#"
+ /// # let lua = Lua::new();
+ /// let thread: Thread = lua.load(r#"
/// coroutine.create(function(arg)
/// assert(arg == 42)
/// local yieldarg = coroutine.yield(123)
/// assert(yieldarg == 43)
/// return 987
/// end)
- /// "#, None).unwrap();
+ /// "#).eval()?;
///
- /// assert_eq!(thread.resume::<_, u32>(42).unwrap(), 123);
- /// assert_eq!(thread.resume::<_, u32>(43).unwrap(), 987);
+ /// assert_eq!(thread.resume::<_, u32>(42)?, 123);
+ /// assert_eq!(thread.resume::<_, u32>(43)?, 987);
///
/// // The coroutine has now returned, so `resume` will fail
/// match thread.resume::<_, u32>(()) {
/// Err(Error::CoroutineInactive) => {},
/// unexpected => panic!("unexpected result {:?}", unexpected),
/// }
+ /// # Ok(())
/// # }
/// ```
pub fn resume<A, R>(&self, args: A) -> Result<R>