diff options
| author | bors <bors@rust-lang.org> | 2019-03-12 18:58:23 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-03-12 18:58:23 +0000 |
| commit | 7c19e1eed5418b8c02be65d678417b241ee01a3e (patch) | |
| tree | 10833a99ac6f165ef304c60f3c8b835c344884e4 /src/libcore/num | |
| parent | d06a020e2b100d8a22252d8877783d8869e5a9ad (diff) | |
| parent | db99a3bccdc21e80d832b061defe1002527c1c46 (diff) | |
| download | rust-7c19e1eed5418b8c02be65d678417b241ee01a3e.tar.gz rust-7c19e1eed5418b8c02be65d678417b241ee01a3e.zip | |
Auto merge of #58015 - icefoxen:tryfrom-docs, r=SimonSapin
Expand docs for `TryFrom` and `TryInto`. The examples are still lacking for now, both for module docs and for methods/impl's. Will be adding those in further pushes. Should hopefully resolve the doc concern in #33417 when finished?
Diffstat (limited to 'src/libcore/num')
| -rw-r--r-- | src/libcore/num/mod.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 98b5fcd3ee4..fb40bccee6a 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -4442,6 +4442,9 @@ macro_rules! try_from_unbounded { impl TryFrom<$source> for $target { type Error = TryFromIntError; + /// Try to create the target number type from a source + /// number type. This returns an error if the source value + /// is outside of the range of the target type. #[inline] fn try_from(value: $source) -> Result<Self, Self::Error> { Ok(value as $target) @@ -4457,6 +4460,9 @@ macro_rules! try_from_lower_bounded { impl TryFrom<$source> for $target { type Error = TryFromIntError; + /// Try to create the target number type from a source + /// number type. This returns an error if the source value + /// is outside of the range of the target type. #[inline] fn try_from(u: $source) -> Result<$target, TryFromIntError> { if u >= 0 { @@ -4476,6 +4482,9 @@ macro_rules! try_from_upper_bounded { impl TryFrom<$source> for $target { type Error = TryFromIntError; + /// Try to create the target number type from a source + /// number type. This returns an error if the source value + /// is outside of the range of the target type. #[inline] fn try_from(u: $source) -> Result<$target, TryFromIntError> { if u > (<$target>::max_value() as $source) { @@ -4495,6 +4504,9 @@ macro_rules! try_from_both_bounded { impl TryFrom<$source> for $target { type Error = TryFromIntError; + /// Try to create the target number type from a source + /// number type. This returns an error if the source value + /// is outside of the range of the target type. #[inline] fn try_from(u: $source) -> Result<$target, TryFromIntError> { let min = <$target>::min_value() as $source; |
