Use Error::from_lua_conversion helper

This commit is contained in:
Alex Orlenko
2026-01-29 20:47:06 +00:00
parent 2fbd266da6
commit 613748ec16
5 changed files with 108 additions and 192 deletions
+5 -5
View File
@@ -446,11 +446,11 @@ impl<T> DerefMut for UserDataRefMutInner<T> {
fn try_value_to_userdata<T>(value: Value) -> Result<AnyUserData> {
match value {
Value::UserData(ud) => Ok(ud),
_ => Err(Error::FromLuaConversionError {
from: value.type_name(),
to: "userdata".to_string(),
message: Some(format!("expected userdata of type {}", type_name::<T>())),
}),
_ => Err(Error::from_lua_conversion(
value.type_name(),
"userdata",
format!("expected userdata of type {}", type_name::<T>()),
)),
}
}