Skip to content

Commit 3ae3d11

Browse files
committed
Add error example
1 parent 096da58 commit 3ae3d11

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

library/core/src/num/mod.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1450,10 +1450,13 @@ macro_rules! from_str_radix {
14501450
/// # Examples
14511451
///
14521452
/// Basic usage:
1453-
///
14541453
/// ```
14551454
#[doc = concat!("assert_eq!(", stringify!($int_ty), "::from_str_radix(\"A\", 16), Ok(10));")]
14561455
/// ```
1456+
/// Trailing space returns error:
1457+
/// ```
1458+
#[doc = concat!("assert_matches!(", stringify!($int_ty), "::from_str_radix(\"1 \", 10), Err(_));")]
1459+
/// ```
14571460
#[stable(feature = "rust1", since = "1.0.0")]
14581461
#[rustc_const_unstable(feature = "const_int_from_str", issue = "59133")]
14591462
pub const fn from_str_radix(src: &str, radix: u32) -> Result<$int_ty, ParseIntError> {
@@ -1591,10 +1594,13 @@ macro_rules! from_str_radix_size_impl {
15911594
/// # Examples
15921595
///
15931596
/// Basic usage:
1594-
///
15951597
/// ```
15961598
#[doc = concat!("assert_eq!(", stringify!($size), "::from_str_radix(\"A\", 16), Ok(10));")]
15971599
/// ```
1600+
/// Trailing space returns error:
1601+
/// ```
1602+
#[doc = concat!("assert_matches!(", stringify!($size), "::from_str_radix(\"1 \", 10), Err(_));")]
1603+
/// ```
15981604
#[stable(feature = "rust1", since = "1.0.0")]
15991605
#[rustc_const_unstable(feature = "const_int_from_str", issue = "59133")]
16001606
pub const fn from_str_radix(src: &str, radix: u32) -> Result<$size, ParseIntError> {

0 commit comments

Comments
 (0)