Skip to content

Commit 7e723d0

Browse files
authored
Add rustfmt.toml to format Rust code in doc comments (#155)
1 parent c27b83e commit 7e723d0

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

rustfmt.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
format_code_in_doc_comments = true

src/int.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//!
1717
//! # Example
1818
//! ```rust
19-
//! use std::ops::{Add, Sub, Mul, Div, Rem};
19+
//! use std::ops::{Add, Div, Mul, Rem, Sub};
2020
//! use typenum::{Integer, N3, P2};
2121
//!
2222
//! assert_eq!(<N3 as Add<P2>>::Output::to_i32(), -1);

src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//! example,
99
//!
1010
//! ```rust
11-
//! use typenum::{N4, Integer};
11+
//! use typenum::{Integer, N4};
1212
//!
1313
//! assert_eq!(N4::to_i32(), -4);
1414
//! ```
@@ -34,14 +34,13 @@
3434
//! could be replaced with
3535
//!
3636
//! ```rust
37-
//! use typenum::{Sum, Integer, P3, P4};
37+
//! use typenum::{Integer, Sum, P3, P4};
3838
//!
3939
//! type X = Sum<P3, P4>;
4040
//! assert_eq!(<X as Integer>::to_i32(), 7);
4141
//! ```
4242
//!
4343
//! Documented in each module is the full list of type operators implemented.
44-
//!
4544
4645
#![no_std]
4746
#![forbid(unsafe_code)]

src/marker_traits.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//! to_i32() -> i32` and the associated constant `I32` so that one can do this:
1010
//!
1111
//! ```
12-
//! use typenum::{N42, Integer};
12+
//! use typenum::{Integer, N42};
1313
//!
1414
//! assert_eq!(-42, N42::to_i32());
1515
//! assert_eq!(-42, N42::I32);
@@ -49,7 +49,7 @@ pub trait Bit: Copy + Default {
4949
///
5050
/// # Example
5151
/// ```rust
52-
/// use typenum::{U3, Unsigned};
52+
/// use typenum::{Unsigned, U3};
5353
///
5454
/// assert_eq!(U3::to_u32(), 3);
5555
/// assert_eq!(U3::I32, 3);
@@ -118,7 +118,7 @@ pub trait Unsigned: Copy + Default {
118118
///
119119
/// # Example
120120
/// ```rust
121-
/// use typenum::{P3, Integer};
121+
/// use typenum::{Integer, P3};
122122
///
123123
/// assert_eq!(P3::to_i32(), 3);
124124
/// assert_eq!(P3::I32, 3);
@@ -171,9 +171,9 @@ pub trait TypeArray {}
171171
/// Here's a working example:
172172
///
173173
/// ```rust
174-
/// use typenum::{P4, P8, PowerOfTwo};
174+
/// use typenum::{PowerOfTwo, P4, P8};
175175
///
176-
/// fn only_p2<P: PowerOfTwo>() { }
176+
/// fn only_p2<P: PowerOfTwo>() {}
177177
///
178178
/// only_p2::<P4>();
179179
/// only_p2::<P8>();

src/type_operators.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use {Bit, NInt, NonZero, PInt, UInt, UTerm, Unsigned, Z0};
1515
///
1616
/// # Example
1717
/// ```rust
18-
/// use typenum::{Same, U4, U5, Unsigned};
18+
/// use typenum::{Same, Unsigned, U4, U5};
1919
///
2020
/// assert_eq!(<U5 as Same<U5>>::Output::to_u32(), 5);
2121
///
@@ -38,7 +38,7 @@ impl<T> Same<T> for T {
3838
///
3939
/// # Example
4040
/// ```rust
41-
/// use typenum::{Abs, N5, Integer};
41+
/// use typenum::{Abs, Integer, N5};
4242
///
4343
/// assert_eq!(<N5 as Abs>::Output::to_i32(), 5);
4444
/// ```
@@ -63,7 +63,7 @@ impl<U: Unsigned + NonZero> Abs for NInt<U> {
6363
///
6464
/// # Example
6565
/// ```rust
66-
/// use typenum::{Pow, N3, P3, Integer};
66+
/// use typenum::{Integer, Pow, N3, P3};
6767
///
6868
/// assert_eq!(<N3 as Pow<P3>>::Output::to_i32(), -27);
6969
/// ```
@@ -550,7 +550,7 @@ pub trait Logarithm2 {
550550
/// # Example
551551
///
552552
/// ```rust
553-
/// use typenum::{Gcd, U12, U8, Unsigned};
553+
/// use typenum::{Gcd, Unsigned, U12, U8};
554554
///
555555
/// assert_eq!(<U12 as Gcd<U8>>::Output::to_i32(), 4);
556556
/// ```

src/uint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//!
1313
//! # Example
1414
//! ```rust
15-
//! use std::ops::{BitAnd, BitOr, BitXor, Shl, Shr, Add, Sub, Mul, Div, Rem};
15+
//! use std::ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Rem, Shl, Shr, Sub};
1616
//! use typenum::{Unsigned, U1, U2, U3, U4};
1717
//!
1818
//! assert_eq!(<U3 as BitAnd<U2>>::Output::to_u32(), 2);
@@ -146,7 +146,7 @@ impl Unsigned for UTerm {
146146
///
147147
/// # Example
148148
/// ```rust
149-
/// use typenum::{B0, B1, UInt, UTerm};
149+
/// use typenum::{UInt, UTerm, B0, B1};
150150
///
151151
/// # #[allow(dead_code)]
152152
/// type U6 = UInt<UInt<UInt<UTerm, B1>, B1>, B0>;

0 commit comments

Comments
 (0)