3 ms·
`?` isn't really that great - for all but toy cases you have to jump through hoops - especially if you are trying to handle different error types from separate
by fnord77 8y ago
`?` isn't really that great - for all but toy cases you have to jump through hoops - especially if you are trying to handle different error types from separate in a unified way.
Not a fan of Result, either - it ties together the error type and the type of the desired item - these should be separate concerns.
- 0815test 8y ago> Not a fan of Result, either - it ties together the error type and the type of the desired item - these should be separate concerns. How so? 'Result' is just a generic variant record with two variant cases, for the "success" and "error" condition. It's the exact same as the `value, err` pattern in Go, except that it additionally enforces proper semantics and handling of the outcome.
- epage 8y ago> `?` isn't really that great - for all but toy cases you have to jump through hoops - especially if you are trying to handle different error types from separate in a unified way. To be clear, that isn't the fault of `?` but that Rust "requires" you to specify your error type. You could just specify `Box<Error>` and go about your day without boiler plate. What you mention and my workaround are two extremes of the solution space. There are Rust crates inbetween that help people handle errors the way they need with minimal boiler plate.