The error handling in rust is mainly based on Result<T, Err>, which is suitable for functions that have return values, especially pure-functional style functions.
What if I need to handle the error condition for in-place updating data member condition?
Say I have some structure with some data member, and I impl some fu for it, which calculate the new value, and write back to self. Such function does not necessarily have return value. What is the proper design pattern for error handling of such kinds of functions?
I understand that at least we can return error code, but it is ugly, isn’t it? Or maybe rust encourages we write codes in a functional-style? but this some times causes low performance.
In languages with exception, we can always throw an exception, what about for rust?