-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: add automatic conversion for nix::Errno
#4060
refactor: add automatic conversion for nix::Errno
#4060
Conversation
it would be nice to test this :) |
@@ -508,6 +508,17 @@ impl From<std::io::Error> for Box<dyn UError> { | |||
} | |||
} | |||
|
|||
impl<T> FromIo<UResult<T>> for Result<T, nix::Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs some comments here :)
and usage examples
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see the function below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GNU testsuite comparison:
|
Cool! This is exactly what I had in mind. I'd just like to have it implemented for |
How can I test it? Is adding usage examples as comments enough?
Do you mean |
You could make a unit test that you know gives an error and assert that the error that you get is correct.
The same as for impl FromIo<Box<UIoError>> for std::io::Error {
fn map_err_context(self, context: impl FnOnce() -> String) -> Box<UIoError> {
Box::new(UIoError {
context: Some((context)()),
inner: self,
})
}
}
impl<T> FromIo<UResult<T>> for std::io::Result<T> {
fn map_err_context(self, context: impl FnOnce() -> String) -> UResult<T> {
self.map_err(|e| e.map_err_context(context) as Box<dyn UError>)
}
} These would also be nice to have for impl From<std::io::Error> for UIoError {
fn from(f: std::io::Error) -> Self {
Self {
context: None,
inner: f,
}
}
}
impl From<std::io::Error> for Box<dyn UError> {
fn from(f: std::io::Error) -> Self {
let u_error: UIoError = f.into();
Box::new(u_error) as Self
}
} |
Could you please fix the clippy warning? thanks |
GNU testsuite comparison:
|
GNU testsuite comparison:
|
I'm not sure why the CI is failing. |
Friendly ping 🏓 |
Just rebased it. It had some job failures |
GNU testsuite comparison:
|
Could you please have a look to https://github.com/uutils/coreutils/actions/runs/3355920132/jobs/5560563514? |
ping? :) |
GNU testsuite comparison:
|
1 similar comment
GNU testsuite comparison:
|
Still not sure why the CI is failing 🤔 |
you can ignore these :) |
An attempt to fix #4007