Rollup merge of #126191 - ivan-shrimp:nonzero_doc, r=scottmcm · model-checking/verify-rust-std@58bb5cf (original) (raw)
`@@ -517,9 +517,13 @@ macro_rules! nonzero_integer {
`
517
517
```` /// ```
`518`
`518`
`/// # use std::num::NonZero;
`
`519`
`519`
`/// #
`
`520`
``
`-
#[doc = concat!("let n = NonZero::<", stringify!($Int), ">::new(", $leading_zeros_test, ").unwrap();")]
`
``
`520`
`+
/// # fn main() { test().unwrap(); }
`
``
`521`
`+
/// # fn test() -> Option<()> {
`
``
`522`
`+
#[doc = concat!("let n = NonZero::<", stringify!($Int), ">::new(", $leading_zeros_test, ")?;")]
`
`521`
`523`
`///
`
`522`
`524`
`/// assert_eq!(n.leading_zeros(), 0);
`
``
`525`
`+
/// # Some(())
`
``
`526`
`+
/// # }
`
`523`
`527`
```` /// ```
524
528
` #[stable(feature = "nonzero_leading_trailing_zeros", since = "1.53.0")]
`
525
529
` #[rustc_const_stable(feature = "nonzero_leading_trailing_zeros", since = "1.53.0")]
`
`@@ -545,9 +549,13 @@ macro_rules! nonzero_integer {
`
545
549
```` /// ```
`546`
`550`
`/// # use std::num::NonZero;
`
`547`
`551`
`/// #
`
`548`
``
`-
#[doc = concat!("let n = NonZero::<", stringify!($Int), ">::new(0b0101000).unwrap();")]
`
``
`552`
`+
/// # fn main() { test().unwrap(); }
`
``
`553`
`+
/// # fn test() -> Option<()> {
`
``
`554`
`+
#[doc = concat!("let n = NonZero::<", stringify!($Int), ">::new(0b0101000)?;")]
`
`549`
`555`
`///
`
`550`
`556`
`/// assert_eq!(n.trailing_zeros(), 3);
`
``
`557`
`+
/// # Some(())
`
``
`558`
`+
/// # }
`
`551`
`559`
```` /// ```
552
560
` #[stable(feature = "nonzero_leading_trailing_zeros", since = "1.53.0")]
`
553
561
` #[rustc_const_stable(feature = "nonzero_leading_trailing_zeros", since = "1.53.0")]
`
`@@ -1101,9 +1109,13 @@ macro_rules! nonzero_integer_signedness_dependent_methods {
`
1101
1109
```` /// ```
`1102`
`1110`
`/// # use std::num::NonZero;
`
`1103`
`1111`
`/// #
`
`1104`
``
`-
#[doc = concat!("assert_eq!(NonZero::new(7", stringify!($Int), ").unwrap().ilog2(), 2);")]
`
`1105`
``
`-
#[doc = concat!("assert_eq!(NonZero::new(8", stringify!($Int), ").unwrap().ilog2(), 3);")]
`
`1106`
``
`-
#[doc = concat!("assert_eq!(NonZero::new(9", stringify!($Int), ").unwrap().ilog2(), 3);")]
`
``
`1112`
`+
/// # fn main() { test().unwrap(); }
`
``
`1113`
`+
/// # fn test() -> Option<()> {
`
``
`1114`
`+
#[doc = concat!("assert_eq!(NonZero::new(7", stringify!($Int), ")?.ilog2(), 2);")]
`
``
`1115`
`+
#[doc = concat!("assert_eq!(NonZero::new(8", stringify!($Int), ")?.ilog2(), 3);")]
`
``
`1116`
`+
#[doc = concat!("assert_eq!(NonZero::new(9", stringify!($Int), ")?.ilog2(), 3);")]
`
``
`1117`
`+
/// # Some(())
`
``
`1118`
`+
/// # }
`
`1107`
`1119`
```` /// ```
1108
1120
` #[stable(feature = "int_log", since = "1.67.0")]
`
1109
1121
` #[rustc_const_stable(feature = "int_log", since = "1.67.0")]
`
`@@ -1126,9 +1138,13 @@ macro_rules! nonzero_integer_signedness_dependent_methods {
`
1126
1138
```` /// ```
`1127`
`1139`
`/// # use std::num::NonZero;
`
`1128`
`1140`
`/// #
`
`1129`
``
`-
#[doc = concat!("assert_eq!(NonZero::new(99", stringify!($Int), ").unwrap().ilog10(), 1);")]
`
`1130`
``
`-
#[doc = concat!("assert_eq!(NonZero::new(100", stringify!($Int), ").unwrap().ilog10(), 2);")]
`
`1131`
``
`-
#[doc = concat!("assert_eq!(NonZero::new(101", stringify!($Int), ").unwrap().ilog10(), 2);")]
`
``
`1141`
`+
/// # fn main() { test().unwrap(); }
`
``
`1142`
`+
/// # fn test() -> Option<()> {
`
``
`1143`
`+
#[doc = concat!("assert_eq!(NonZero::new(99", stringify!($Int), ")?.ilog10(), 1);")]
`
``
`1144`
`+
#[doc = concat!("assert_eq!(NonZero::new(100", stringify!($Int), ")?.ilog10(), 2);")]
`
``
`1145`
`+
#[doc = concat!("assert_eq!(NonZero::new(101", stringify!($Int), ")?.ilog10(), 2);")]
`
``
`1146`
`+
/// # Some(())
`
``
`1147`
`+
/// # }
`
`1132`
`1148`
```` /// ```
1133
1149
` #[stable(feature = "int_log", since = "1.67.0")]
`
1134
1150
` #[rustc_const_stable(feature = "int_log", since = "1.67.0")]
`
`@@ -1187,10 +1203,16 @@ macro_rules! nonzero_integer_signedness_dependent_methods {
`
1187
1203
`/// Basic usage:
`
1188
1204
`///
`
1189
1205
```` /// ```
`1190`
``
`-
#[doc = concat!("let eight = std::num::NonZero::new(8", stringify!($Int), ").unwrap();")]
`
``
`1206`
`+
/// # use std::num::NonZero;
`
``
`1207`
`+
/// #
`
``
`1208`
`+
/// # fn main() { test().unwrap(); }
`
``
`1209`
`+
/// # fn test() -> Option<()> {
`
``
`1210`
`+
#[doc = concat!("let eight = NonZero::new(8", stringify!($Int), ")?;")]
`
`1191`
`1211`
`/// assert!(eight.is_power_of_two());
`
`1192`
``
`-
#[doc = concat!("let ten = std::num::NonZero::new(10", stringify!($Int), ").unwrap();")]
`
``
`1212`
`+
#[doc = concat!("let ten = NonZero::new(10", stringify!($Int), ")?;")]
`
`1193`
`1213`
`/// assert!(!ten.is_power_of_two());
`
``
`1214`
`+
/// # Some(())
`
``
`1215`
`+
/// # }
`
`1194`
`1216`
```` /// ```
1195
1217
` #[must_use]
`
1196
1218
` #[stable(feature = "nonzero_is_power_of_two", since = "1.59.0")]
`