Error should impl PartialEq
yjhmelody opened this issue · 6 comments
I find now Error is bad to be compared.
Error cannot impl PartialEq beacuse of ExternalError, I think ExternalError should not be a dyn error.
And some error enum like FromLuaConversionError:
/// A Lua value could not be converted to the expected Rust type.
FromLuaConversionError {
/// Name of the Lua type that could not be converted.
from: &'static str,
/// Name of the Rust type that could not be created.
to: &'static str,
/// A string containing more detailed error information.
message: Option<StdString>,
},
should have their own struct.
Hi,
What's your use case for the error implementing PartialEq
? This isn't the norm - e.g. std::io::Error
doesn't.
Thanks!
io::Error's error message are more dynamic. But most of rlua Error are static.
But ExternalError
is a feature - it means that Rust callbacks can return their own error type, which will be propagated through Lua - it's a feature. I think this is more useful than comparing errors for equality; I'm afraid I don't see a compelling reason to try to change this.
Lua errors can be completely arbitrary, including error({})
, error(function() end)
, error(nil)
, error(coroutine.create(function() end))
, etc.
@SoniEx2 In this case we're talking about the Rust-side Error
enum, which only has Rust types.
Closing as this is as designed.