Skip to content

Commit 675d092

Browse files
committed
doc: panicking division by zero examples for unsigned strict div ops
1 parent fdc56b6 commit 675d092

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

library/core/src/num/uint_macros.rs

+27
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,13 @@ macro_rules! uint_impl {
793793
/// #![feature(strict_overflow_ops)]
794794
#[doc = concat!("assert_eq!(100", stringify!($SelfT), ".strict_div(10), 10);")]
795795
/// ```
796+
///
797+
/// The following panics because of division by zero:
798+
///
799+
/// ```should_panic
800+
/// #![feature(strict_overflow_ops)]
801+
#[doc = concat!("let _ = (1", stringify!($SelfT), ").strict_div(0);")]
802+
/// ```
796803
#[unstable(feature = "strict_overflow_ops", issue = "118260")]
797804
#[rustc_const_unstable(feature = "const_strict_overflow_ops", issue = "118260")]
798805
#[must_use = "this returns the result of the operation, \
@@ -848,6 +855,12 @@ macro_rules! uint_impl {
848855
/// #![feature(strict_overflow_ops)]
849856
#[doc = concat!("assert_eq!(100", stringify!($SelfT), ".strict_div_euclid(10), 10);")]
850857
/// ```
858+
/// The following panics because of division by zero:
859+
///
860+
/// ```should_panic
861+
/// #![feature(strict_overflow_ops)]
862+
#[doc = concat!("let _ = (1", stringify!($SelfT), ").strict_div_euclid(0);")]
863+
/// ```
851864
#[unstable(feature = "strict_overflow_ops", issue = "118260")]
852865
#[rustc_const_unstable(feature = "const_strict_overflow_ops", issue = "118260")]
853866
#[must_use = "this returns the result of the operation, \
@@ -903,6 +916,13 @@ macro_rules! uint_impl {
903916
/// #![feature(strict_overflow_ops)]
904917
#[doc = concat!("assert_eq!(100", stringify!($SelfT), ".strict_rem(10), 0);")]
905918
/// ```
919+
///
920+
/// The following panics because of division by zero:
921+
///
922+
/// ```should_panic
923+
/// #![feature(strict_overflow_ops)]
924+
#[doc = concat!("let _ = 5", stringify!($SelfT), ".strict_rem(0);")]
925+
/// ```
906926
#[unstable(feature = "strict_overflow_ops", issue = "118260")]
907927
#[rustc_const_unstable(feature = "const_strict_overflow_ops", issue = "118260")]
908928
#[must_use = "this returns the result of the operation, \
@@ -959,6 +979,13 @@ macro_rules! uint_impl {
959979
/// #![feature(strict_overflow_ops)]
960980
#[doc = concat!("assert_eq!(100", stringify!($SelfT), ".strict_rem_euclid(10), 0);")]
961981
/// ```
982+
///
983+
/// The following panics because of division by zero:
984+
///
985+
/// ```should_panic
986+
/// #![feature(strict_overflow_ops)]
987+
#[doc = concat!("let _ = 5", stringify!($SelfT), ".strict_rem_euclid(0);")]
988+
/// ```
962989
#[unstable(feature = "strict_overflow_ops", issue = "118260")]
963990
#[rustc_const_unstable(feature = "const_strict_overflow_ops", issue = "118260")]
964991
#[must_use = "this returns the result of the operation, \

0 commit comments

Comments
 (0)