News for hackers. Stuff that matters.
Re:Sshole by itishappy on Thursday November 05, 2026 @10:13PM (#50387717)
> In Rust, if you have an thing that returns Result<String, String> that's still type safe, even though success and error types are the same.

These types are not the same:

    Ok<String>
    Err<String>
Re:Sshole by markasoftware on Friday November 06, 2026 @12:57AM (#50388711)
Those are not types at all. Ok and Err are type constructors for the Result<A, B> type that take arguments of type A and B respectively.
Re:Sshole by SkiFire13 on Friday November 06, 2026 @02:00AM (#50389078)
> type constructors

Nit: the type constructor is `Result`: given two types `A` and `B` (not instances of those types, but actual types) it gives you a new type `Result<A, B>`.

`Ok` and `Err` are called "variants" and can be used to construct a new _instance_ of `Result<A, B>`.

Re:Sshole by markasoftware on Friday November 06, 2026 @04:41PM (#50398887)
Ah, thanks! I'd remembered the term "data constructor" from Haskell and called it a type constructor instead.
Re:Sshole by kazinator on Friday November 06, 2026 @06:52PM (#50400123)
[delayed]