mirror of
https://github.com/mlua-rs/mlua
synced 2026-06-08 16:05:43 +00:00
serde_userdata: Remove map_err to reduce compile time impact (#441)
This commit is contained in:
committed by
GitHub
parent
c58f67b140
commit
26b9bdb362
@@ -7,6 +7,7 @@
|
||||
- `Lua::replace_registry_value` takes `&mut RegistryKey`
|
||||
- `Lua::scope` temporary disabled (will be re-added in the next release)
|
||||
- Reduced the compile time contribution of `next_key_seed` and `next_value_seed`.
|
||||
- Reduced the compile time contribution of `serde_userdata`.
|
||||
|
||||
## v0.9.9
|
||||
|
||||
|
||||
+7
-2
@@ -719,6 +719,11 @@ fn serde_userdata<V>(
|
||||
ud: AnyUserData,
|
||||
f: impl FnOnce(serde_value::Value) -> std::result::Result<V, serde_value::DeserializerError>,
|
||||
) -> Result<V> {
|
||||
let value = serde_value::to_value(ud).map_err(|err| Error::SerializeError(err.to_string()))?;
|
||||
f(value).map_err(|err| Error::DeserializeError(err.to_string()))
|
||||
match serde_value::to_value(ud) {
|
||||
Ok(value) => match f(value) {
|
||||
Ok(r) => Ok(r),
|
||||
Err(error) => Err(Error::DeserializeError(error.to_string())),
|
||||
},
|
||||
Err(error) => Err(Error::SerializeError(error.to_string())),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user