Skip to content

Commit

Permalink
Cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
cmpute committed Jan 6, 2024
1 parent c2a6266 commit 2380949
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 40 deletions.
2 changes: 1 addition & 1 deletion float/src/repr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ impl<const B: Word> Repr<B> {
}

/// Create an Repr from a static sequence of [Word][crate::Word]s representing the significand.
///
///
/// This method is intended for static creation macros.
#[doc(hidden)]
#[rustversion::since(1.64)]
Expand Down
16 changes: 8 additions & 8 deletions integer/src/bits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ impl UBig {
/// assert_eq!(UBig::from(0b101000000u16).trailing_zeros(), Some(6));
/// assert_eq!(UBig::ZERO.trailing_zeros(), None);
/// ```
///
///
/// # Availability
///
///
/// Const since Rust 1.64
#[rustversion::attr(since(1.64), const)]
#[inline]
Expand All @@ -82,9 +82,9 @@ impl UBig {
/// assert_eq!(UBig::from(0b101001111u16).trailing_ones(), Some(4));
/// assert_eq!(UBig::ZERO.trailing_ones(), Some(0));
/// ```
///
///
/// # Availability
///
///
/// Const since Rust 1.64
#[rustversion::attr(since(1.64), const)]
#[inline]
Expand Down Expand Up @@ -223,9 +223,9 @@ impl IBig {
/// assert_eq!(IBig::from(-0b101000000).trailing_zeros(), Some(6));
/// assert_eq!(IBig::ZERO.trailing_zeros(), None);
/// ```
///
///
/// # Availability
///
///
/// Const since Rust 1.64
#[rustversion::attr(since(1.64), const)]
#[inline]
Expand All @@ -249,9 +249,9 @@ impl IBig {
/// assert_eq!(IBig::from(-0b101000001).trailing_ones(), Some(6));
/// assert_eq!(IBig::NEG_ONE.trailing_ones(), None);
/// ```
///
///
/// # Availability
///
///
/// Const since Rust 1.64
#[rustversion::attr(since(1.64), const)]
pub fn trailing_ones(&self) -> Option<usize> {
Expand Down
8 changes: 4 additions & 4 deletions integer/src/div_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,9 @@ impl UBig {
}

/// A const version of [UBig::is_multiple_of], but only accepts [DoubleWord][crate::DoubleWord] divisors.
///
///
/// # Availability
///
///
/// Since Rust 1.64
#[rustversion::since(1.64)]
#[inline]
Expand Down Expand Up @@ -699,9 +699,9 @@ impl IBig {
}

/// A const version of [IBig::is_multiple_of], but only accepts [DoubleWord][crate::DoubleWord] divisors.
///
///
/// # Availability
///
///
/// Since Rust 1.64
#[rustversion::since(1.64)]
#[inline]
Expand Down
6 changes: 4 additions & 2 deletions integer/src/repr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ impl Repr {
&[lo, hi] => {
assert!(hi > 0);
Self::from_dword(double_word(lo, hi))
},
}
large => {
// this condition is always true, use this expression because unwrap() is not const
if let Some(n) = large.last() {
Expand All @@ -305,7 +305,9 @@ impl Repr {

let ptr = large.as_ptr() as _;
Self {
data: ReprData { heap: (ptr, large.len()) },
data: ReprData {
heap: (ptr, large.len()),
},
capacity: NonZeroIsize::new_unchecked(large.len() as _),
}
}
Expand Down
2 changes: 1 addition & 1 deletion macros/src/parse/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn parse_integer(
input: TokenStream,
) -> TokenStream {
let (sign, big) = unwrap_with_error_msg(parse_integer_with_error(signed, input));

let ns = if embedded {
quote!(::dashu::integer)
} else {
Expand Down
4 changes: 2 additions & 2 deletions macros/src/parse/ratio.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{
common::{quote_sign, unwrap_with_error_msg, quote_words},
common::{quote_sign, quote_words, unwrap_with_error_msg},
int::{quote_ibig, quote_ubig},
};

Expand Down Expand Up @@ -51,7 +51,7 @@ pub fn parse_ratio(embedded: bool, input: TokenStream) -> TokenStream {

pub fn parse_static_ratio(embedded: bool, input: TokenStream) -> TokenStream {
let (num, den, relaxed) = unwrap_with_error_msg(parse_ratio_with_error(input));

let ns = if embedded {
quote!(::dashu::rational)
} else {
Expand Down
2 changes: 1 addition & 1 deletion macros/tests/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn test_static_ubig() {

let one: &'static UBig = static_ubig!(1);
assert_eq!(*one, UBig::ONE);

let medium1: &'static UBig = static_ubig!(0xfffffffffffffff);
assert_eq!(*medium1, UBig::from(0xfffffffffffffffu64));
let medium2: &'static UBig = static_ubig!(0xfffffffffffffffff);
Expand Down
52 changes: 32 additions & 20 deletions macros/tests/ratio.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::str::FromStr;

use dashu_macros::{static_rbig, rbig};
use dashu_macros::{rbig, static_rbig};
use dashu_ratio::{RBig, Relaxed};

#[test]
Expand All @@ -15,8 +15,14 @@ fn test_rbig() {
assert_eq!(rbig!(c/d base 32), RBig::from_str_radix("c/d", 32).unwrap());
assert_eq!(rbig!(-12_34 / 56_78), RBig::from_str("-1234/5678").unwrap());
assert_eq!(rbig!(-12_34 / -56_78), RBig::from_str("1234/5678").unwrap());
assert_eq!(rbig!(-2/-123456789012345678901234567), RBig::from_str("2/123456789012345678901234567").unwrap());
assert_eq!(rbig!(-987654321098765432109876543/-2), RBig::from_str("987654321098765432109876543/2").unwrap());
assert_eq!(
rbig!(-2 / -123456789012345678901234567),
RBig::from_str("2/123456789012345678901234567").unwrap()
);
assert_eq!(
rbig!(-987654321098765432109876543 / -2),
RBig::from_str("987654321098765432109876543/2").unwrap()
);

// const test
const _: RBig = rbig!(0);
Expand All @@ -32,16 +38,16 @@ fn test_static_rbig() {

let one: &'static RBig = static_rbig!(1);
assert_eq!(*one, RBig::ONE);
let medium: &'static RBig =
static_rbig!(-1234567890123456789/9876543210987654323);
assert_eq!(
*medium,
RBig::from_str("-1234567890123456789/9876543210987654323").unwrap()
);

let medium1: &'static RBig = static_rbig!(-1234567890123456789 / 9876543210987654323);
assert_eq!(*medium1, RBig::from_str("-1234567890123456789/9876543210987654323").unwrap());
let medium2: &'static RBig = static_rbig!(1234567890123456789 / 2);
assert_eq!(*medium2, RBig::from_str("1234567890123456789/2").unwrap());
let medium3: &'static RBig = static_rbig!(-2 / 9876543210987654323);
assert_eq!(*medium3, RBig::from_str("-2/9876543210987654323").unwrap());

let big: &'static RBig =
static_rbig!(-123456789012345678901234567/987654321098765432109876543);
static_rbig!(-123456789012345678901234567 / 987654321098765432109876543);
assert_eq!(
*big,
RBig::from_str("-123456789012345678901234567/987654321098765432109876543").unwrap()
Expand All @@ -60,8 +66,14 @@ fn test_relaxed() {
assert_eq!(rbig!(~c/d base 32), Relaxed::from_str_radix("c/d", 32).unwrap());
assert_eq!(rbig!(~-12_34/56_78), Relaxed::from_str("-1234/5678").unwrap());
assert_eq!(rbig!(~-12_34/56_78), Relaxed::from_str("-1234/5678").unwrap());
assert_eq!(rbig!(~2/-123456789012345678901234567), Relaxed::from_str("-2/123456789012345678901234567").unwrap());
assert_eq!(rbig!(~987654321098765432109876543/-2), Relaxed::from_str("-987654321098765432109876543/2").unwrap());
assert_eq!(
rbig!(~2/-123456789012345678901234567),
Relaxed::from_str("-2/123456789012345678901234567").unwrap()
);
assert_eq!(
rbig!(~987654321098765432109876543/-2),
Relaxed::from_str("-987654321098765432109876543/2").unwrap()
);

// const test
const _: Relaxed = rbig!(~0);
Expand All @@ -77,13 +89,13 @@ fn test_static_relaxed() {

let one: &'static Relaxed = static_rbig!(~1);
assert_eq!(*one, Relaxed::ONE);
let medium: &'static Relaxed =
static_rbig!(~-123456789012345678/987654321098765432);
assert_eq!(
*medium,
Relaxed::from_str("-123456789012345678/987654321098765432").unwrap()
);

let medium1: &'static Relaxed = static_rbig!(~-123456789012345678 / 987654321098765432);
assert_eq!(*medium1, Relaxed::from_str("-123456789012345678/987654321098765432").unwrap());
let medium2: &'static Relaxed = static_rbig!(~123456789012345678 / 2);
assert_eq!(*medium2, Relaxed::from_str("123456789012345678/2").unwrap());
let medium3: &'static Relaxed = static_rbig!(~-2 / 987654321098765432);
assert_eq!(*medium3, Relaxed::from_str("-2/987654321098765432").unwrap());

let big: &'static Relaxed =
static_rbig!(~-123456789012345678901234567/987654321098765432109876543);
Expand Down
2 changes: 1 addition & 1 deletion rational/src/rbig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ impl Relaxed {

/// Create an Relaxed instance from two static sequences of [Word][crate::Word]s representing the
/// numerator and denominator.
///
///
/// This method is intended for static creation macros.
#[doc(hidden)]
#[rustversion::since(1.64)]
Expand Down

0 comments on commit 2380949

Please sign in to comment.