FYI, there's already a method on Option that is unwrap() with an error
message: expect().

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.


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

> On 06/12/2013 20:55, Léo Testard wrote:
>
>> Hi,
>>
>> Just a suggestion, don't know what it's worth...
>>
>> For the "not helpful error message" thing, couldn't we extend the
>> option API, to be able to specify at the creation of a None value
>> the error string that will be displayed if one calls unwrap() on this
>> value ? This may be useful in several situations.
>>
>
> That would require making the memory representation of every Option
> bigger. Just for the (hopefully) uncommon case of task failure, it’s not
> worth the cost in my opinion.
>
> We could instead have .unwrap() that take an error message, but that
> leaves the responsibility to the user of the API.
>
>
> --
> 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