Why not use Result instead of Option for these types of things? Result is
already defined to be able to return error codes using Err. The only way to
indicate an error when returning an Option is to return None which doesn't
allow for that. Also, IMO, None doesn't necessarily mean "error" to me.
Lets say we have a function defined as:

fn do_something(value: Option<~str>);

It seems like it would be much to easy to accidentally write something
like: do_something(str::from_utf8(...)) which might result in the error
being hidden since do_something might not consider None to be an error
input.

-Palmer Cox



On Fri, Dec 6, 2013 at 4:52 PM, Simon Sapin <simon.sa...@exyr.org> wrote:

> On 06/12/2013 21:50, Eric Reed wrote:
>
>> Personally, I prefer making functions that don't fail and use Option or
>> Result and then composing them with functions that fail for certain
>> outputs, but I think I'm in the minority there.
>>
>
> Yes, this is what I’m suggesting.
>
>
> --
> Simon Sapin
> _______________________________________________
> Rust-dev mailing list
> Rust-dev@mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
>
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to