From 6874c2e004f9fa92add76f1ddb4076bf80fd90ad Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Thu, 17 Oct 2019 16:59:33 +0100 Subject: Fix examples and docs --- src/thread.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/thread.rs') 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(&self, args: A) -> Result -- cgit v1.2.3