Skip to content

Commit 8d810c1

Browse files
committed
Change imports to vertical
1 parent 4a31e0a commit 8d810c1

24 files changed

Lines changed: 284 additions & 64 deletions

.rustfmt.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ hard_tabs = false
3535
hide_parse_errors = false
3636
ignore = []
3737
imports_indent = "Block"
38-
imports_layout = "HorizontalVertical" # handles lots of imports better
38+
imports_layout = "Vertical" # makes editing quicker
3939
indent_style = "Block"
4040
inline_attribute_width = 0 # unchanged, for ease of editing
4141
# license_template_path = "LICENSE_TEMPLATE" # changed
@@ -71,4 +71,4 @@ use_small_heuristics = "Default"
7171
use_try_shorthand = true # changed
7272
version = "Two" # changed
7373
where_single_line = false # unchanged, for ease of editing
74-
wrap_comments = true # fits comments to the line
74+
wrap_comments = true # fits comments to the line

src/apint/arithmetic.rs

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,42 @@ use crate::{
33
utils::{
44
DataAccessMut,
55
ZipDataAccessMutBoth,
6-
ZipDataAccessMutSelf::{Ext, Inl},
6+
ZipDataAccessMutSelf::{
7+
Ext,
8+
Inl,
9+
},
710
},
811
ApInt,
912
},
1013
digit,
11-
digit::{Digit, DoubleDigit},
12-
errors::{DivOp, Error, Result},
13-
mem::{vec, vec::Vec},
14+
digit::{
15+
Digit,
16+
DoubleDigit,
17+
},
18+
errors::{
19+
DivOp,
20+
Error,
21+
Result,
22+
},
23+
mem::{
24+
vec,
25+
vec::Vec,
26+
},
1427
traits::Width,
15-
utils::{forward_mut_impl, try_forward_bin_mut_impl},
28+
utils::{
29+
forward_mut_impl,
30+
try_forward_bin_mut_impl,
31+
},
32+
};
33+
use core::ops::{
34+
Add,
35+
AddAssign,
36+
Mul,
37+
MulAssign,
38+
Neg,
39+
Sub,
40+
SubAssign,
1641
};
17-
use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};
1842

1943
// Moved here because of a bug in rustfmt. This entire file will be broken up in
2044
// a future commit. assigns `$sum + $sub` to `$target`,
@@ -1915,7 +1939,10 @@ mod tests {
19151939
mod mul {
19161940
use super::*;
19171941
use crate::bitwidth::BitWidth;
1918-
use core::{u64, u8};
1942+
use core::{
1943+
u64,
1944+
u8,
1945+
};
19191946

19201947
#[test]
19211948
fn rigorous() {

src/apint/bitwise.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use crate::{
22
apint::{
3-
utils::{DataAccess, DataAccessMut},
3+
utils::{
4+
DataAccess,
5+
DataAccessMut,
6+
},
47
ApInt,
58
},
69
bitpos::BitPos,
@@ -9,10 +12,21 @@ use crate::{
912
digit::Bit,
1013
errors::Result,
1114
traits::Width,
12-
utils::{forward_mut_impl, try_forward_bin_mut_impl},
15+
utils::{
16+
forward_mut_impl,
17+
try_forward_bin_mut_impl,
18+
},
1319
};
1420

15-
use core::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Not};
21+
use core::ops::{
22+
BitAnd,
23+
BitAndAssign,
24+
BitOr,
25+
BitOrAssign,
26+
BitXor,
27+
BitXorAssign,
28+
Not,
29+
};
1630

1731
/// # Bitwise Operations
1832
impl ApInt {

src/apint/casting.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@ use crate::{
22
apint::ApInt,
33
bitwidth::BitWidth,
44
digit::Bit,
5-
errors::{Error, Result},
5+
errors::{
6+
Error,
7+
Result,
8+
},
69
mem::format,
710
storage::Storage,
811
traits::Width,
9-
utils::{forward_bin_mut_impl, try_forward_bin_mut_impl},
12+
utils::{
13+
forward_bin_mut_impl,
14+
try_forward_bin_mut_impl,
15+
},
1016
};
1117

1218
impl Clone for ApInt {
@@ -732,7 +738,10 @@ mod tests {
732738

733739
#[test]
734740
fn regression_issue15() {
735-
use core::{i128, i64};
741+
use core::{
742+
i128,
743+
i64,
744+
};
736745
{
737746
let input = ApInt::from_i64(i64::MIN)
738747
.into_sign_extend(BitWidth::new(128).unwrap())

src/apint/constructors.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
use crate::{
2-
apint::{ApInt, ApIntData},
2+
apint::{
3+
ApInt,
4+
ApIntData,
5+
},
36
bitwidth::BitWidth,
47
digit,
5-
digit::{Bit, Digit},
6-
errors::{Error, Result},
8+
digit::{
9+
Bit,
10+
Digit,
11+
},
12+
errors::{
13+
Error,
14+
Result,
15+
},
716
mem::vec::Vec,
817
storage::Storage,
918
};
@@ -422,7 +431,10 @@ mod tests {
422431
}
423432

424433
mod tests {
425-
use super::{powers, powers_from_to};
434+
use super::{
435+
powers,
436+
powers_from_to,
437+
};
426438

427439
#[test]
428440
fn test_powers() {
@@ -616,7 +628,10 @@ mod tests {
616628

617629
#[test]
618630
fn from_w128() {
619-
use crate::digit::{Digit, DigitRepr};
631+
use crate::digit::{
632+
Digit,
633+
DigitRepr,
634+
};
620635
for val in test_values_u128() {
621636
let explicit_u128 = ApInt::from_u128(val);
622637
let explicit_i128 = ApInt::from_i128(val as i128);

src/apint/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ mod rand_impl;
1414
#[cfg(feature = "serde_support")]
1515
mod serde_impl;
1616

17-
use crate::{bitwidth::BitWidth, digit::Digit};
17+
use crate::{
18+
bitwidth::BitWidth,
19+
digit::Digit,
20+
};
1821

1922
pub use self::shift::ShiftAmount;
2023
pub(crate) use self::to_primitive::PrimitiveTy;

src/apint/rand_impl.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
use crate::{apint::ApInt, bitwidth::BitWidth, digit::Digit};
1+
use crate::{
2+
apint::ApInt,
3+
bitwidth::BitWidth,
4+
digit::Digit,
5+
};
26
use rand::SeedableRng as _;
37

48
impl rand::distributions::Distribution<Digit> for rand::distributions::Standard {
@@ -28,7 +32,10 @@ impl ApInt {
2832
{
2933
let required_digits = width.required_digits();
3034
assert!(required_digits >= 1);
31-
use rand::distributions::{Distribution, Standard};
35+
use rand::distributions::{
36+
Distribution,
37+
Standard,
38+
};
3239
let random_digits = Standard.sample_iter(rng).take(required_digits);
3340
// The truncation will be cheap always!
3441
ApInt::from_iter(random_digits)
@@ -58,7 +65,10 @@ impl ApInt {
5865
where
5966
R: rand::Rng,
6067
{
61-
use rand::distributions::{Distribution, Standard};
68+
use rand::distributions::{
69+
Distribution,
70+
Standard,
71+
};
6272
let std_dist = Standard.sample_iter(rng);
6373
self.digits_mut().zip(std_dist).for_each(|(d, r)| *d = r);
6474
self.clear_unused_bits();

src/apint/relational.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
use crate::{
2-
apint::{utils::ZipDataAccess, ApInt},
2+
apint::{
3+
utils::ZipDataAccess,
4+
ApInt,
5+
},
36
digit,
47
digit::Bit,
58
errors::Result,
69
mem::format,
710
traits::Width,
811
};
9-
use core::{cmp::Ordering, ops::Not};
12+
use core::{
13+
cmp::Ordering,
14+
ops::Not,
15+
};
1016

1117
/// If `self` and `other` have unmatching bit widths, `false` will be returned.
1218
impl PartialEq for ApInt {

src/apint/serde_impl.rs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
use crate::{apint::ApInt, bitwidth::BitWidth, digit::Digit};
1+
use crate::{
2+
apint::ApInt,
3+
bitwidth::BitWidth,
4+
digit::Digit,
5+
};
26

3-
use serde::{ser::SerializeTupleStruct, Serialize, Serializer};
7+
use serde::{
8+
ser::SerializeTupleStruct,
9+
Serialize,
10+
Serializer,
11+
};
412

513
impl Serialize for Digit {
614
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
@@ -31,7 +39,10 @@ impl Serialize for ApInt {
3139
where
3240
S: Serializer,
3341
{
34-
use serde::ser::{SerializeStruct, SerializeTuple};
42+
use serde::ser::{
43+
SerializeStruct,
44+
SerializeTuple,
45+
};
3546

3647
if serializer.is_human_readable() {
3748
let mut s = serializer.serialize_struct("ApInt", 2)?;
@@ -50,7 +61,11 @@ impl Serialize for ApInt {
5061
use core::fmt;
5162
use serde::{
5263
de,
53-
de::{MapAccess, SeqAccess, Visitor},
64+
de::{
65+
MapAccess,
66+
SeqAccess,
67+
Visitor,
68+
},
5469
Deserialize,
5570
Deserializer,
5671
};
@@ -296,7 +311,10 @@ impl<'de> Deserialize<'de> for ApInt {
296311
mod tests {
297312
use super::*;
298313

299-
use serde_test::{assert_tokens, Token};
314+
use serde_test::{
315+
assert_tokens,
316+
Token,
317+
};
300318

301319
mod compact {
302320
use super::*;

src/apint/serialization.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
use crate::{
22
apint::ApInt,
33
digit,
4-
errors::{Error, Result},
5-
mem::{string::String, vec::Vec},
4+
errors::{
5+
Error,
6+
Result,
7+
},
8+
mem::{
9+
string::String,
10+
vec::Vec,
11+
},
612
radix::Radix,
713
};
814
use core::fmt;
@@ -190,7 +196,10 @@ impl ApInt {
190196
//
191197
// TODO: Better document what happens here and why.
192198
fn from_bitwise_digits(v: &[u8], bits: usize) -> ApInt {
193-
use crate::digit::{Digit, DigitRepr};
199+
use crate::digit::{
200+
Digit,
201+
DigitRepr,
202+
};
194203

195204
debug_assert!(!v.is_empty() && bits <= 8 && digit::BITS % bits == 0);
196205
debug_assert!(v.iter().all(|&c| DigitRepr::from(c) < (1 << bits)));
@@ -217,7 +226,10 @@ impl ApInt {
217226
//
218227
// TODO: Better document what happens here and why.
219228
fn from_inexact_bitwise_digits(v: &[u8], bits: usize) -> ApInt {
220-
use crate::digit::{Digit, DigitRepr};
229+
use crate::digit::{
230+
Digit,
231+
DigitRepr,
232+
};
221233

222234
debug_assert!(!v.is_empty() && bits <= 8 && digit::BITS % bits != 0);
223235
debug_assert!(v.iter().all(|&c| (DigitRepr::from(c)) < (1 << bits)));
@@ -259,7 +271,10 @@ impl ApInt {
259271
// TODO: This does not work, yet. Some parts of the algorithm are
260272
// commented-out since the required functionality does not exist, yet.
261273
fn from_radix_digits(v: &[u8], radix: Radix) -> ApInt {
262-
use crate::digit::{Digit, DigitRepr};
274+
use crate::digit::{
275+
Digit,
276+
DigitRepr,
277+
};
263278
#[cfg(feature = "libm_0")]
264279
use libm::F64Ext as _;
265280

0 commit comments

Comments
 (0)