Skip to content

Commit

Permalink
NumCast: document when from can return None
Browse files Browse the repository at this point in the history
  • Loading branch information
ocstl committed Oct 18, 2019
1 parent 16cdce3 commit 27e3f85
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
}

Expand Down

0 comments on commit 27e3f85

Please sign in to comment.