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
Change the default context selector suffix to Snafu #286
Conversation
dd06ca4
to
ea0a324
Compare
Hopefully dropping a comment here isn't too forward ^^;; I routinely use a pattern like this with snafu:
|
Not at all!
Presumably this would create the module and then place the error and selectors into it, similar to what is described in #188? Ultimately, I don't think that approach can work. Note that your example uses At best, you'd have to provide fully-qualified paths for many of the variant fields. |
Oh, yes. That's pretty much it exactly.
Right. I would've needed to
I was speaking more about the restrictions on what identifiers escape a macro. I think there are some rules on it, and I'm absolutely not familiar with them.
Would you be able to expand the derive macro to a module with either:
I doubt (1) would work with So: use dependency::SomeOtherError;
#[derive(Debug, Snafu)]
#[snafu(module)] // Let's pretend that `module` does a camel to snake-case conversion, and `module(...)` lets you name it?
pub enum ParseError {
SomeOther { source: SomeOtherError },
} Would expand to something like: use dependency::SomeOtherError;
#[derive(Debug)]
pub enum ParseError {
// ...
}
pub(crate) mod parse_error {
use super::*;
pub(crate) SomeOther {
// ...
}
} |
I can see that working in many cases, but it'd probably fall down for some other cases: #[derive(Snafu,Debug)]
pub enum ParseError {
Thing { source: super::Error },
}
I'm not a fan of the module-focused view. My personal direction is that each module should have it's own error type and selectors. The selectors should only be used in that module. That being said, it seems that both solutions can coexist. Would you be interested in (a) taking this discussion to #188 and/or (b) attempting to implement it? |
No description provided.