@@ -4544,6 +4544,9 @@ macro_rules! try_from_unbounded {
4544
4544
impl TryFrom <$source> for $target {
4545
4545
type Error = TryFromIntError ;
4546
4546
4547
+ /// Try to create the target type from the source type.
4548
+ /// This particular variant will never fail, but is included
4549
+ /// for completeness's sake.
4547
4550
#[ inline]
4548
4551
fn try_from( value: $source) -> Result <Self , Self :: Error > {
4549
4552
Ok ( value as $target)
@@ -4559,6 +4562,10 @@ macro_rules! try_from_lower_bounded {
4559
4562
impl TryFrom <$source> for $target {
4560
4563
type Error = TryFromIntError ;
4561
4564
4565
+ /// Try to create a target number type from a
4566
+ /// source type that has `source::MIN > dest::MIN`.
4567
+ /// Will return an error if `source` is less than
4568
+ /// `dest::MIN`.
4562
4569
#[ inline]
4563
4570
fn try_from( u: $source) -> Result <$target, TryFromIntError > {
4564
4571
if u >= 0 {
@@ -4578,6 +4585,10 @@ macro_rules! try_from_upper_bounded {
4578
4585
impl TryFrom <$source> for $target {
4579
4586
type Error = TryFromIntError ;
4580
4587
4588
+ /// Try to create a target number type from a
4589
+ /// source type that has `source::MAX > dest::MAX`.
4590
+ /// Will return an error if `source` is greater than
4591
+ /// `dest::MAX`.
4581
4592
#[ inline]
4582
4593
fn try_from( u: $source) -> Result <$target, TryFromIntError > {
4583
4594
if u > ( <$target>:: max_value( ) as $source) {
@@ -4597,6 +4608,11 @@ macro_rules! try_from_both_bounded {
4597
4608
impl TryFrom <$source> for $target {
4598
4609
type Error = TryFromIntError ;
4599
4610
4611
+ /// Try to "narrow" a number from the source type
4612
+ /// to the target type. Will return an error if
4613
+ /// the source value is either larger than the
4614
+ /// `MAX` value for the target type or smaller
4615
+ /// than the `MIN` value for it.
4600
4616
#[ inline]
4601
4617
fn try_from( u: $source) -> Result <$target, TryFromIntError > {
4602
4618
let min = <$target>:: min_value( ) as $source;
0 commit comments