diff options
author | Alex Orlenko <zxteam@protonmail.com> | 2023-03-28 14:41:21 +0100 |
---|---|---|
committer | Alex Orlenko <zxteam@protonmail.com> | 2023-03-28 16:27:16 +0100 |
commit | e182d474e035a5e1f5234982c857470c54d686fe (patch) | |
tree | 9972d30d27cb6e78aada90ac17a7b4782bd4dbf5 /mlua_derive/src | |
parent | 0f937b0a03de657249898b75cbdc1575215424de (diff) | |
download | mlua-e182d474e035a5e1f5234982c857470c54d686fe.zip |
More user-friendly error message about missing value for `name` attribute in module macro
Update the `[lua_module]` doc
Diffstat (limited to 'mlua_derive/src')
-rw-r--r-- | mlua_derive/src/lib.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/mlua_derive/src/lib.rs b/mlua_derive/src/lib.rs index 6267a02..b5128fc 100644 --- a/mlua_derive/src/lib.rs +++ b/mlua_derive/src/lib.rs @@ -18,7 +18,14 @@ struct ModuleAttributes { impl ModuleAttributes { fn parse(&mut self, meta: ParseNestedMeta) -> Result<()> { if meta.path.is_ident("name") { - self.name = Some(meta.value()?.parse::<LitStr>()?.parse()?); + match meta.value() { + Ok(value) => { + self.name = Some(value.parse::<LitStr>()?.parse()?); + } + Err(_) => { + return Err(meta.error(format!("`name` attribute must have a value"))); + } + } } else { return Err(meta.error("unsupported module attribute")); } |