-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Closed
Description
Two reasons:
- Different types need to deal with this differently (see examples below). Having only one way to do it causes confusion, because it forces you to return an
Option, even when the function cannot returnNone. The standard library is full of calls followed byunwrap. - It is not useful to provide a generic way to do it (please correct me if I am wrong).
Examples:
- No function of
FromPrimitivecan ever returnNoneforBigInt - Only the functions which accept negative numbers can return
NoneforBigUint - For the primitive types, each one has different constraints. For example,
FromPrimitive::<i8>::from_i32can returnNonebecause of overflow, whileFromPrimitive::<f64>::from_i32cannot.
The only problem I see is in libtest/stats.rs, where FromPrimitive is used generically. I think however that we can figure it out.
I think the best solution would be have different implementations for each type.
cc @aturon
griffi-gh and claraphyllstepancheg and griffi-gh
Metadata
Metadata
Assignees
Labels
No labels