NumCast: document when `from` can return `None`
This commit is contained in:
parent
16cdce31d4
commit
27e3f853b0
|
@ -639,7 +639,8 @@ pub fn cast<T: NumCast, U: NumCast>(n: T) -> Option<U> {
|
|||
/// An interface for casting between machine scalars.
|
||||
pub trait NumCast: Sized + ToPrimitive {
|
||||
/// Creates a number from another value that can be converted into
|
||||
/// a primitive via the `ToPrimitive` trait.
|
||||
/// a primitive via the `ToPrimitive` trait. If the source value cannot be
|
||||
/// represented by the target type, then `None` is returned.
|
||||
fn from<T: ToPrimitive>(n: T) -> Option<Self>;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue