shepmaster / snafu

Easily assign underlying errors into domain-specific errors while adding context
https://docs.rs/snafu/
Apache License 2.0
1.45k stars 61 forks source link

Suggestion: Default impl for selectors without additional fields #234

Open fan-tom opened 4 years ago

fan-tom commented 4 years ago

Inspired by #233: derive Default for selectors without fields (unit structs). That will allow having generic context selectors, to allow caller choose which error type function must return. Although, I'm not sure it is good idea in general, because it looks like implementation detail leak, as I described in mentioned issue, I think it may be useful in some cases, if function performs one well known thing (one cause of fail, no need to parametrize over multiple selector types), especially with generics defaults, when function returns it's own error type, if caller didn't provide custom selector.