• Asetru@feddit.org
    link
    fedilink
    arrow-up
    23
    arrow-down
    5
    ·
    5 months ago

    The or() combinator means exactly one succeeds.

    Using “or” to define a function that does “xor”… Did that guy never hear about formal logic? That’s, like, first or second semester stuff…

    Here’s the thing: I don’t have a CS degree.

    sigh

      • Asetru@feddit.org
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        4 months ago

        The result type in rust does not return a true/false but a type. More importantly though, it doesn’t return err if both values are set but simply returns the first value:

        So… It’s not only not mapping your input to truth values, it also behaves more like I’d expect an “or” to behave, which is not “xor” or, if there’s more than two inputs, “exactly one”, but succeeding if any input is set.

          • Asetru@feddit.org
            link
            fedilink
            arrow-up
            1
            ·
            4 months ago

            Absolutely not.

            Mutually exclusive options

            Another classic. Pick one output format: JSON, YAML, or XML. But definitely not two.

            Emphasis mine.

            It takes the input and fails if there is more than one valid one, which decidedly isn’t what’s an “or” in comp sci.