7
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
this post was submitted on 19 Nov 2024
7 points (100.0% liked)
Rust Programming
9373 readers
1 users here now
founded 7 years ago
MODERATORS
You can't create a subset of an enum directly, but splitting this up into multiple types works. You can have
FunctionAErrorwith errors that function can produce and a variant for your common errors, andFunctionBErrorwhich is similar:The try operator (
?) will automatically useFromimpls to convert errors for you as well. If a function returns a result containingMyErrorCommonin your function and you use?on it, it gets converted to that function's error type for you.thiserrorgenerates theFromimpl for you if you use#[from].