Explorar o código

NumCast: document when `from` can return `None`

Olivier Chassé St-Laurent %!s(int64=5) %!d(string=hai) anos
pai
achega
27e3f853b0
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  1. 2 1
      src/cast.rs

+ 2 - 1
src/cast.rs

@@ -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>;
 }