Skip to content

Commit c37d8da

Browse files
authored
Unrolled build for #153197
Rollup merge of #153197 - sorairolake:change-doctests-style, r=joboet style: Update doctests for `TryFrom<integer> for bool` and `From<bool> for float` These doctests are attached to the `TryFrom` trait and the `From` trait. Although `From<U> for T` implies `Into<T> for U` and `TryFrom<U> for T` implies `TryInto<T> for U`, I think it is easier to understand to use the `try_from`/`from` method directly instead of the `try_into`/`into` method.
2 parents 38c0de8 + af35716 commit c37d8da

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

  • library/core/src/convert

library/core/src/convert/num.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,11 @@ macro_rules! impl_float_from_bool {
198198
/// # Examples
199199
/// ```
200200
$($(#[doc = $doctest_prefix])*)?
201-
#[doc = concat!("let x: ", stringify!($float)," = false.into();")]
201+
#[doc = concat!("let x = ", stringify!($float), "::from(false);")]
202202
/// assert_eq!(x, 0.0);
203203
/// assert!(x.is_sign_positive());
204204
///
205-
#[doc = concat!("let y: ", stringify!($float)," = true.into();")]
205+
#[doc = concat!("let y = ", stringify!($float), "::from(true);")]
206206
/// assert_eq!(y, 1.0);
207207
$($(#[doc = $doctest_suffix])*)?
208208
/// ```
@@ -343,11 +343,11 @@ macro_rules! impl_try_from_integer_for_bool {
343343
/// # Examples
344344
///
345345
/// ```
346-
#[doc = concat!("assert_eq!(0_", stringify!($int), ".try_into(), Ok(false));")]
346+
#[doc = concat!("assert_eq!(bool::try_from(0_", stringify!($int), "), Ok(false));")]
347347
///
348-
#[doc = concat!("assert_eq!(1_", stringify!($int), ".try_into(), Ok(true));")]
348+
#[doc = concat!("assert_eq!(bool::try_from(1_", stringify!($int), "), Ok(true));")]
349349
///
350-
#[doc = concat!("assert!(<", stringify!($int), " as TryInto<bool>>::try_into(2).is_err());")]
350+
#[doc = concat!("assert!(bool::try_from(2_", stringify!($int), ").is_err());")]
351351
/// ```
352352
#[inline]
353353
fn try_from(i: $int) -> Result<Self, Self::Error> {

0 commit comments

Comments
 (0)