Hacker News
points by ethin 3 days ago | 0 comments
Rust would not save you here as this is a logic bug. Nor would, well, really any other language. I suppose someone might claim that Rust's result type would save you but it really wouldn't: I can easily make the error type a String or pretty much any other type with little consequence.
[–] K0nserv 3 days ago
Rust would absolutely have saved you here. Even with `Result<String, String>`, which is pretty poor design, there's no confusing `Ok(s)` with `Err(s)`. Sure you can go out of your way to write something like

    let hash = match result {
        OK(s) => s,
        Err(s) => s,
    };
but at that point I feel like the library is forgiven (except for the poor error design).

@my-huge-pony does make a good point elsewhere in the thread: if the potential error was not foreseen and the code was written originally to return `String` instead of `Result<String, Error>` then even Rust would be in a pickle.

[–] iknowstuff 3 days ago
It would, due to Result<T> and #[must_use] on it. Nobody would return “*” as a sentinel in Rust.
[–] slopinthebag 2 days ago
languages with more features would mean developers aren't choosing between unchecked NULLs or sentinel strings.