points by K0nserv 3 days ago | 0 comments
`Option<String>` or `Result<String>` forces the check at the callsite. Unlike C, you cannot forget that the function can error. This absolutely helps prevent issues like this.
Now, the decision to return `"*"` instead of letting poorly written code crash on `NULL` is not good either.
[–] pheggs 2 days ago
[–] _flux 2 days ago
Given how easy it is to just forward that error to the caller, I think most Rust developers would just choose to do that.
[–] uecker 2 days ago
[–] K0nserv 2 days ago
That's exactly what you get with Result and Option, it's impossible to forget.
Compare:
To:[–] pheggs 2 days ago
[–] K0nserv 2 days ago
[–] pheggs 2 days ago
[–] slopinthebag 2 days ago
[–] pheggs 2 days ago
[–] K0nserv 2 days ago