From 3589cd465e7302e9bd058fa568b0e9ea0d5bc981 Mon Sep 17 00:00:00 2001 From: jerry73204 Date: Sat, 25 Jul 2020 06:04:03 +0800 Subject: [PATCH] Add rustfmt.toml to format Rust code in doc comments --- rustfmt.toml | 1 + src/int.rs | 2 +- src/lib.rs | 5 ++--- src/marker_traits.rs | 10 +++++----- src/type_operators.rs | 8 ++++---- src/uint.rs | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) create mode 100644 rustfmt.toml diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 000000000..16bdde911 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1 @@ +format_code_in_doc_comments = true diff --git a/src/int.rs b/src/int.rs index 6d0e887e2..2d3ed34da 100644 --- a/src/int.rs +++ b/src/int.rs @@ -16,7 +16,7 @@ //! //! # Example //! ```rust -//! use std::ops::{Add, Sub, Mul, Div, Rem}; +//! use std::ops::{Add, Div, Mul, Rem, Sub}; //! use typenum::{Integer, N3, P2}; //! //! assert_eq!(>::Output::to_i32(), -1); diff --git a/src/lib.rs b/src/lib.rs index 022fa655c..7402390f0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,7 @@ //! example, //! //! ```rust -//! use typenum::{N4, Integer}; +//! use typenum::{Integer, N4}; //! //! assert_eq!(N4::to_i32(), -4); //! ``` @@ -34,14 +34,13 @@ //! could be replaced with //! //! ```rust -//! use typenum::{Sum, Integer, P3, P4}; +//! use typenum::{Integer, Sum, P3, P4}; //! //! type X = Sum; //! assert_eq!(::to_i32(), 7); //! ``` //! //! Documented in each module is the full list of type operators implemented. -//! #![no_std] #![forbid(unsafe_code)] diff --git a/src/marker_traits.rs b/src/marker_traits.rs index ee071989f..e411f026b 100644 --- a/src/marker_traits.rs +++ b/src/marker_traits.rs @@ -9,7 +9,7 @@ //! to_i32() -> i32` and the associated constant `I32` so that one can do this: //! //! ``` -//! use typenum::{N42, Integer}; +//! use typenum::{Integer, N42}; //! //! assert_eq!(-42, N42::to_i32()); //! assert_eq!(-42, N42::I32); @@ -49,7 +49,7 @@ pub trait Bit: Copy + Default { /// /// # Example /// ```rust -/// use typenum::{U3, Unsigned}; +/// use typenum::{Unsigned, U3}; /// /// assert_eq!(U3::to_u32(), 3); /// assert_eq!(U3::I32, 3); @@ -118,7 +118,7 @@ pub trait Unsigned: Copy + Default { /// /// # Example /// ```rust -/// use typenum::{P3, Integer}; +/// use typenum::{Integer, P3}; /// /// assert_eq!(P3::to_i32(), 3); /// assert_eq!(P3::I32, 3); @@ -171,9 +171,9 @@ pub trait TypeArray {} /// Here's a working example: /// /// ```rust -/// use typenum::{P4, P8, PowerOfTwo}; +/// use typenum::{PowerOfTwo, P4, P8}; /// -/// fn only_p2() { } +/// fn only_p2() {} /// /// only_p2::(); /// only_p2::(); diff --git a/src/type_operators.rs b/src/type_operators.rs index 84628dff0..4a3d440b5 100644 --- a/src/type_operators.rs +++ b/src/type_operators.rs @@ -15,7 +15,7 @@ use {Bit, NInt, NonZero, PInt, UInt, UTerm, Unsigned, Z0}; /// /// # Example /// ```rust -/// use typenum::{Same, U4, U5, Unsigned}; +/// use typenum::{Same, Unsigned, U4, U5}; /// /// assert_eq!(>::Output::to_u32(), 5); /// @@ -38,7 +38,7 @@ impl Same for T { /// /// # Example /// ```rust -/// use typenum::{Abs, N5, Integer}; +/// use typenum::{Abs, Integer, N5}; /// /// assert_eq!(::Output::to_i32(), 5); /// ``` @@ -63,7 +63,7 @@ impl Abs for NInt { /// /// # Example /// ```rust -/// use typenum::{Pow, N3, P3, Integer}; +/// use typenum::{Integer, Pow, N3, P3}; /// /// assert_eq!(>::Output::to_i32(), -27); /// ``` @@ -550,7 +550,7 @@ pub trait Logarithm2 { /// # Example /// /// ```rust -/// use typenum::{Gcd, U12, U8, Unsigned}; +/// use typenum::{Gcd, Unsigned, U12, U8}; /// /// assert_eq!(>::Output::to_i32(), 4); /// ``` diff --git a/src/uint.rs b/src/uint.rs index 12825627c..1d09c78cf 100644 --- a/src/uint.rs +++ b/src/uint.rs @@ -12,7 +12,7 @@ //! //! # Example //! ```rust -//! use std::ops::{BitAnd, BitOr, BitXor, Shl, Shr, Add, Sub, Mul, Div, Rem}; +//! use std::ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Rem, Shl, Shr, Sub}; //! use typenum::{Unsigned, U1, U2, U3, U4}; //! //! assert_eq!(>::Output::to_u32(), 2); @@ -146,7 +146,7 @@ impl Unsigned for UTerm { /// /// # Example /// ```rust -/// use typenum::{B0, B1, UInt, UTerm}; +/// use typenum::{UInt, UTerm, B0, B1}; /// /// # #[allow(dead_code)] /// type U6 = UInt, B1>, B0>;