4 ms·
There's also helper crates like eyre simplifying the process of adding context even further (at the cost of type erasure): foo().context("oh no")?
by aldanor 3y ago
There's also helper crates like eyre simplifying the process of adding context even further (at the cost of type erasure):
foo().context("oh no")?
- josephcsible 3y agoWhat do you mean by "at the cost of type erasure"? Isn't type erasure an attribute of a programming language and not something that a library has control over?
- aldanor 3y agoIn this case, it means your actual error will be packed and boxed someplace behind a smart pointer, its type will be lost (so you wouldn't be able to match on its specific variants downstream might you want to) but it will be still able to format itself to a string and will comply with std::error::Error trait.