Skip to content

Commit

Permalink
Doc test hide use statements for ethnum types
Browse files Browse the repository at this point in the history
  • Loading branch information
nlordell committed Oct 25, 2023
1 parent 811cec8 commit 1256fbd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
4 changes: 4 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "Rust",
"image": "mcr.microsoft.com/devcontainers/rust:1-1-bookworm"
}
24 changes: 8 additions & 16 deletions src/int/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,7 @@ impl I256 {
/// Basic usage:
///
/// ```
/// # use ethnum::I256;
/// use ethnum::U256;
/// # use ethnum::{I256, U256};
/// assert_eq!(I256::new(1).checked_add_unsigned(U256::new(2)), Some(I256::new(3)));
/// assert_eq!((I256::MAX - 2).checked_add_unsigned(U256::new(3)), None);
/// ```
Expand Down Expand Up @@ -501,8 +500,7 @@ impl I256 {
/// Basic usage:
///
/// ```
/// # use ethnum::I256;
/// use ethnum::U256;
/// # use ethnum::{I256, U256};
/// assert_eq!(I256::new(1).checked_sub_unsigned(U256::new(2)), Some(I256::new(-1)));
/// assert_eq!((I256::MIN + 2).checked_sub_unsigned(U256::new(3)), None);
/// ```
Expand Down Expand Up @@ -806,8 +804,7 @@ impl I256 {
/// Basic usage:
///
/// ```
/// # use ethnum::I256;
/// use ethnum::U256;
/// # use ethnum::{I256, U256};
/// assert_eq!(I256::new(1).saturating_add_unsigned(U256::new(2)), 3);
/// assert_eq!(I256::MAX.saturating_add_unsigned(U256::new(100)), I256::MAX);
/// ```
Expand Down Expand Up @@ -859,8 +856,7 @@ impl I256 {
/// Basic usage:
///
/// ```
/// # use ethnum::I256;
/// use ethnum::U256;
/// # use ethnum::{I256, U256};
/// assert_eq!(I256::new(100).saturating_sub_unsigned(U256::new(127)), -27);
/// assert_eq!(I256::MIN.saturating_sub_unsigned(U256::new(100)), I256::MIN);
/// ```
Expand Down Expand Up @@ -1029,8 +1025,7 @@ impl I256 {
/// Basic usage:
///
/// ```
/// # use ethnum::I256;
/// use ethnum::U256;
/// # use ethnum::{I256, U256};
/// assert_eq!(I256::new(100).wrapping_add_unsigned(U256::new(27)), 127);
/// assert_eq!(I256::MAX.wrapping_add_unsigned(U256::new(2)), I256::MIN + 1);
/// ```
Expand Down Expand Up @@ -1070,8 +1065,7 @@ impl I256 {
/// Basic usage:
///
/// ```
/// # use ethnum::I256;
/// use ethnum::U256;
/// # use ethnum::{I256, U256};
/// assert_eq!(I256::new(0).wrapping_sub_unsigned(U256::new(127)), -127);
/// assert_eq!(I256::new(-2).wrapping_sub_unsigned(U256::MAX), -1);
/// ```
Expand Down Expand Up @@ -1428,8 +1422,7 @@ impl I256 {
/// Basic usage:
///
/// ```
/// # use ethnum::I256;
/// use ethnum::U256;
/// # use ethnum::{I256, U256};
/// assert_eq!(I256::new(1).overflowing_add_unsigned(U256::new(2)), (I256::new(3), false));
/// assert_eq!((I256::MIN).overflowing_add_unsigned(U256::MAX), (I256::MAX, false));
/// assert_eq!((I256::MAX - 2).overflowing_add_unsigned(U256::new(3)), (I256::MIN, true));
Expand Down Expand Up @@ -1478,8 +1471,7 @@ impl I256 {
/// Basic usage:
///
/// ```
/// # use ethnum::I256;
/// use ethnum::U256;
/// # use ethnum::{I256, U256};
/// assert_eq!(I256::new(1).overflowing_sub_unsigned(U256::new(2)), (I256::new(-1), false));
/// assert_eq!((I256::MAX).overflowing_sub_unsigned(U256::MAX), (I256::MIN, false));
/// assert_eq!((I256::MIN + 2).overflowing_sub_unsigned(U256::new(3)), (I256::MAX, true));
Expand Down
12 changes: 4 additions & 8 deletions src/uint/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,7 @@ impl U256 {
/// Basic usage:
///
/// ```
/// # use ethnum::U256;
/// use ethnum::I256;
/// # use ethnum::{I256, U256};
/// assert_eq!(U256::new(1).checked_add_signed(I256::new(2)), Some(U256::new(3)));
/// assert_eq!(U256::new(1).checked_add_signed(I256::new(-2)), None);
/// assert_eq!((U256::MAX - 2).checked_add_signed(I256::new(3)), None);
Expand Down Expand Up @@ -727,8 +726,7 @@ impl U256 {
/// Basic usage:
///
/// ```
/// # use ethnum::U256;
/// use ethnum::I256;
/// # use ethnum::{I256, U256};
/// assert_eq!(U256::new(1).saturating_add_signed(I256::new(2)), U256::new(3));
/// assert_eq!(U256::new(1).saturating_add_signed(I256::new(-2)), U256::new(0));
/// assert_eq!((U256::MAX - 2).saturating_add_signed(I256::new(4)), U256::MAX);
Expand Down Expand Up @@ -863,8 +861,7 @@ impl U256 {
/// Basic usage:
///
/// ```
/// # use ethnum::U256;
/// use ethnum::I256;
/// # use ethnum::{I256, U256};
/// assert_eq!(U256::new(1).wrapping_add_signed(I256::new(2)), U256::new(3));
/// assert_eq!(U256::new(1).wrapping_add_signed(I256::new(-2)), U256::MAX);
/// assert_eq!((U256::MAX - 2).wrapping_add_signed(I256::new(4)), U256::new(1));
Expand Down Expand Up @@ -1173,8 +1170,7 @@ impl U256 {
/// Basic usage:
///
/// ```
/// # use ethnum::U256;
/// use ethnum::I256;
/// # use ethnum::{I256, U256};
/// assert_eq!(U256::new(1).overflowing_add_signed(I256::new(2)), (U256::new(3), false));
/// assert_eq!(U256::new(1).overflowing_add_signed(I256::new(-2)), (U256::MAX, true));
/// assert_eq!((U256::MAX - 2).overflowing_add_signed(I256::new(4)), (U256::new(1), true));
Expand Down

0 comments on commit 1256fbd

Please sign in to comment.