@@ -4544,9 +4544,14 @@ macro_rules! try_from_unbounded {
45444544 impl TryFrom <$source> for $target {
45454545 type Error = TryFromIntError ;
45464546
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+ /// Try to create the target number type from a source
4548+ /// number type. If the source type has a larger range
4549+ /// than the target, or their ranges are disjoint (such
4550+ /// as converting a signed to unsigned number or vice
4551+ /// versa), this will return `None` if the source value
4552+ /// doesn't fit into the range of the destination value.
4553+ /// If the conversion can never fail, this is still
4554+ /// implemented for completeness's sake.
45504555 #[ inline]
45514556 fn try_from( value: $source) -> Result <Self , Self :: Error > {
45524557 Ok ( value as $target)
@@ -4562,10 +4567,14 @@ macro_rules! try_from_lower_bounded {
45624567 impl TryFrom <$source> for $target {
45634568 type Error = TryFromIntError ;
45644569
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`.
4570+ /// Try to create the target number type from a source
4571+ /// number type. If the source type has a larger range
4572+ /// than the target, or their ranges are disjoint (such
4573+ /// as converting a signed to unsigned number or vice
4574+ /// versa), this will return `None` if the source value
4575+ /// doesn't fit into the range of the destination value.
4576+ /// If the conversion can never fail, this is still
4577+ /// implemented for completeness's sake.
45694578 #[ inline]
45704579 fn try_from( u: $source) -> Result <$target, TryFromIntError > {
45714580 if u >= 0 {
@@ -4585,10 +4594,14 @@ macro_rules! try_from_upper_bounded {
45854594 impl TryFrom <$source> for $target {
45864595 type Error = TryFromIntError ;
45874596
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`.
4597+ /// Try to create the target number type from a source
4598+ /// number type. If the source type has a larger range
4599+ /// than the target, or their ranges are disjoint (such
4600+ /// as converting a signed to unsigned number or vice
4601+ /// versa), this will return `None` if the source value
4602+ /// doesn't fit into the range of the destination value.
4603+ /// If the conversion can never fail, this is still
4604+ /// implemented for completeness's sake.
45924605 #[ inline]
45934606 fn try_from( u: $source) -> Result <$target, TryFromIntError > {
45944607 if u > ( <$target>:: max_value( ) as $source) {
@@ -4608,11 +4621,14 @@ macro_rules! try_from_both_bounded {
46084621 impl TryFrom <$source> for $target {
46094622 type Error = TryFromIntError ;
46104623
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.
4624+ /// Try to create the target number type from a source
4625+ /// number type. If the source type has a larger range
4626+ /// than the target, or their ranges are disjoint (such
4627+ /// as converting a signed to unsigned number or vice
4628+ /// versa), this will return `None` if the source value
4629+ /// doesn't fit into the range of the destination value.
4630+ /// If the conversion can never fail, this is still
4631+ /// implemented for completeness's sake.
46164632 #[ inline]
46174633 fn try_from( u: $source) -> Result <$target, TryFromIntError > {
46184634 let min = <$target>:: min_value( ) as $source;
0 commit comments