▲ | Ygg2 a day ago | |
> Once every return is a Result, every call a ?, and every error a yeet The Try operator (`?`) is just a syntax sugar for return. You are free to ignore it. Just write the nested return. People like it for succinctness. Yeet? I don't understand, do you mean the unstable operator? Rust doesn't have errors either. > what's the difference between your program and one with exceptions except the Result program being syntactically noisy and full of footguns? Exceptions keep the stacktrace, and have to be caught. They behave similar to panics. If panics were heavy and could be caught. Rust errors aren't caught, they must be dealt with in whatever method invokes them. Try operator by being noisy, tells you - "Hey, you're potentially returning here". That's a feature. Having many return in method can both be a smell, or it could be fine. I can find what lines potentially return (by searching for `?`). An exception can be mostly ignored, until it bubbles up god knows where. THAT IS A HUGE FOOTGUN. In Java/C# every line in your program becomes a quiet return. You can't find what line returns because EVERY LINE CAN. |