Update AsChunk::env function prototype

This commit is contained in:
Alex Orlenko
2021-06-21 23:19:33 +01:00
parent c702c5eff2
commit f24fdfdb80
2 changed files with 8 additions and 11 deletions
+5 -8
View File
@@ -2074,7 +2074,7 @@ pub struct Chunk<'lua, 'a> {
lua: &'lua Lua,
source: &'a [u8],
name: Option<CString>,
env: Option<Result<Value<'lua>>>,
env: Result<Option<Value<'lua>>>,
mode: Option<ChunkMode>,
}
@@ -2101,8 +2101,8 @@ pub trait AsChunk<'lua> {
/// Returns optional chunk [environment]
///
/// [environment]: https://www.lua.org/manual/5.3/manual.html#2.2
fn env(&self, _lua: &'lua Lua) -> Option<Result<Value<'lua>>> {
None
fn env(&self, _lua: &'lua Lua) -> Result<Option<Value<'lua>>> {
Ok(None)
}
/// Returns optional chunk mode (text or binary)
@@ -2137,7 +2137,7 @@ impl<'lua, 'a> Chunk<'lua, 'a> {
/// useful.
pub fn set_environment<V: ToLua<'lua>>(mut self, env: V) -> Result<Chunk<'lua, 'a>> {
// Prefer to propagate errors here and wrap to `Ok`
self.env = Some(Ok(env.to_lua(self.lua)?));
self.env = Ok(Some(env.to_lua(self.lua)?));
Ok(self)
}
@@ -2268,10 +2268,7 @@ impl<'lua, 'a> Chunk<'lua, 'a> {
}
fn env(&self) -> Result<Option<Value<'lua>>> {
match self.env {
None => Ok(None),
Some(ref env) => env.clone().map(Some),
}
self.env.clone()
}
fn expression_source(&self) -> Vec<u8> {