Kaynağa Gözat

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

Olivier Chassé St-Laurent 5 yıl önce
ebeveyn
işleme
27e3f853b0
1 değiştirilmiş dosya ile 2 ekleme ve 1 silme
  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>;
 }