Skip to content

Commit 56ca838

Browse files
committed
Use edition 2018 (fixes #138)
along with minor changes: - bump minimum rustc version to 1.31 - tidy doc comments Thanks WildCryptoFox for previous work!
1 parent 3589cd4 commit 56ca838

File tree

10 files changed

+126
-133
lines changed

10 files changed

+126
-133
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ rust:
33
- stable
44
- beta
55
- nightly
6-
- 1.22.0
6+
- 1.31.0
77
cache: cargo
88
os:
99
- linux

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
license = "MIT/Apache-2.0"
1313
description = "Typenum is a Rust library for type-level numbers evaluated at compile time. It currently supports bits, unsigned integers, and signed integers. It also provides a type-level array of type-level numbers, but its implementation is incomplete."
1414
categories = ["no-std"]
15+
edition = "2018"
1516

1617
[lib]
1718
name = "typenum"

build/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ We also define the aliases `False` and `True` for `B0` and `B1`, respectively.
151151
*/
152152
#[allow(missing_docs)]
153153
pub mod consts {{
154-
use uint::{{UInt, UTerm}};
155-
use int::{{PInt, NInt}};
154+
use crate::uint::{{UInt, UTerm}};
155+
use crate::int::{{PInt, NInt}};
156156
157-
pub use bit::{{B0, B1}};
158-
pub use int::Z0;
157+
pub use crate::bit::{{B0, B1}};
158+
pub use crate::int::Z0;
159159
160160
pub type True = B1;
161161
pub type False = B0;

src/bit.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010
//! - From `typenum`: `Same` and `Cmp`.
1111
//!
1212
13+
use crate::{private::InternalMarker, Cmp, Equal, Greater, Less, NonZero, PowerOfTwo};
1314
use core::ops::{BitAnd, BitOr, BitXor, Not};
14-
use private::InternalMarker;
15-
use {Cmp, Equal, Greater, Less, NonZero, PowerOfTwo};
1615

17-
pub use marker_traits::Bit;
16+
pub use crate::marker_traits::Bit;
1817

1918
/// The type-level bit 0.
2019
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
@@ -248,7 +247,7 @@ impl Cmp<B1> for B1 {
248247
}
249248
}
250249

251-
use Min;
250+
use crate::Min;
252251
impl Min<B0> for B0 {
253252
type Output = B0;
254253
#[inline]
@@ -278,7 +277,7 @@ impl Min<B1> for B1 {
278277
}
279278
}
280279

281-
use Max;
280+
use crate::Max;
282281
impl Max<B0> for B0 {
283282
type Output = B0;
284283
#[inline]

src/int.rs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,17 @@
2525
//! assert_eq!(<N3 as Div<P2>>::Output::to_i32(), -1);
2626
//! assert_eq!(<N3 as Rem<P2>>::Output::to_i32(), -1);
2727
//! ```
28-
//!
2928
29+
pub use crate::marker_traits::Integer;
30+
use crate::{
31+
bit::{Bit, B0, B1},
32+
consts::{N1, P1, U0, U1},
33+
private::{Internal, InternalMarker, PrivateDivInt, PrivateIntegerAdd, PrivateRem},
34+
uint::{UInt, Unsigned},
35+
Cmp, Equal, Greater, Less, NonZero, Pow, PowerOfTwo,
36+
};
3037
use core::ops::{Add, Div, Mul, Neg, Rem, Sub};
3138

32-
use bit::{Bit, B0, B1};
33-
use consts::{N1, P1, U0, U1};
34-
use private::{Internal, InternalMarker};
35-
use private::{PrivateDivInt, PrivateIntegerAdd, PrivateRem};
36-
use uint::{UInt, Unsigned};
37-
use {Cmp, Equal, Greater, Less, NonZero, Pow, PowerOfTwo};
38-
39-
pub use marker_traits::Integer;
40-
4139
/// Type-level signed integers with positive sign.
4240
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
4341
pub struct PInt<U: Unsigned + NonZero> {
@@ -610,7 +608,7 @@ impl_int_div!(NInt, NInt, PInt);
610608
// ---------------------------------------------------------------------------------------
611609
// PartialDiv
612610

613-
use {PartialDiv, Quot};
611+
use crate::{PartialDiv, Quot};
614612

615613
impl<M, N> PartialDiv<N> for M
616614
where
@@ -888,7 +886,7 @@ where
888886

889887
// ---------------------------------------------------------------------------------------
890888
// Gcd
891-
use {Gcd, Gcf};
889+
use crate::{Gcd, Gcf};
892890

893891
impl Gcd<Z0> for Z0 {
894892
type Output = Z0;
@@ -960,7 +958,7 @@ where
960958

961959
// ---------------------------------------------------------------------------------------
962960
// Min
963-
use {Max, Maximum, Min, Minimum};
961+
use crate::{Max, Maximum, Min, Minimum};
964962

965963
impl Min<Z0> for Z0 {
966964
type Output = Z0;
@@ -1179,8 +1177,7 @@ where
11791177

11801178
#[cfg(test)]
11811179
mod tests {
1182-
use consts::*;
1183-
use Integer;
1180+
use crate::{consts::*, Integer};
11841181

11851182
#[test]
11861183
fn to_ix_min() {

src/lib.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,16 @@ pub mod uint;
8686

8787
pub mod array;
8888

89-
pub use consts::*;
90-
pub use generated::consts;
91-
pub use marker_traits::*;
92-
pub use operator_aliases::*;
93-
pub use type_operators::*;
94-
95-
pub use array::{ATerm, TArr};
96-
pub use int::{NInt, PInt};
97-
pub use uint::{UInt, UTerm};
89+
pub use crate::{
90+
array::{ATerm, TArr},
91+
consts::*,
92+
generated::consts,
93+
int::{NInt, PInt},
94+
marker_traits::*,
95+
operator_aliases::*,
96+
type_operators::*,
97+
uint::{UInt, UTerm},
98+
};
9899

99100
/// A potential output from `Cmp`, this is the type equivalent to the enum variant
100101
/// `core::cmp::Ordering::Greater`.

src/operator_aliases.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@
77
//!
88
//! ```rust
99
//! # #[macro_use] extern crate typenum;
10-
//! # fn main() {
1110
//! use std::ops::Mul;
1211
//! use typenum::{Prod, P5, P7};
1312
//!
1413
//! type X = <P7 as Mul<P5>>::Output;
1514
//! type Y = Prod<P7, P5>;
1615
//!
1716
//! assert_type_eq!(X, Y);
18-
//! # }
1917
//! ```
2018
//!
2119
//!
2220
2321
// Aliases!!!
22+
use crate::type_operators::{
23+
Abs, Cmp, Gcd, Len, Logarithm2, Max, Min, PartialDiv, Pow, SquareRoot,
24+
};
2425
use core::ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Neg, Rem, Shl, Shr, Sub};
25-
use type_operators::{Abs, Cmp, Gcd, Len, Logarithm2, Max, Min, PartialDiv, Pow, SquareRoot};
2626

2727
/// Alias for the associated type of `BitAnd`: `And<A, B> = <A as BitAnd<B>>::Output`
2828
pub type And<A, B> = <A as BitAnd<B>>::Output;
@@ -64,12 +64,12 @@ pub type Exp<A, B> = <A as Pow<B>>::Output;
6464
pub type Gcf<A, B> = <A as Gcd<B>>::Output;
6565

6666
/// Alias to make it easy to add 1: `Add1<A> = <A as Add<B1>>::Output`
67-
pub type Add1<A> = <A as Add<::bit::B1>>::Output;
67+
pub type Add1<A> = <A as Add<crate::bit::B1>>::Output;
6868
/// Alias to make it easy to subtract 1: `Sub1<A> = <A as Sub<B1>>::Output`
69-
pub type Sub1<A> = <A as Sub<::bit::B1>>::Output;
69+
pub type Sub1<A> = <A as Sub<crate::bit::B1>>::Output;
7070

7171
/// Alias to make it easy to multiply by 2. `Double<A> = Shleft<A, B1>`
72-
pub type Double<A> = Shleft<A, ::bit::B1>;
72+
pub type Double<A> = Shleft<A, crate::bit::B1>;
7373

7474
/// Alias to make it easy to square. `Square<A> = <A as Mul<A>>::Output`
7575
pub type Square<A> = <A as Mul>::Output;
@@ -91,7 +91,9 @@ pub type Minimum<A, B> = <A as Min<B>>::Output;
9191
/// Alias for the associated type of `Max`: `Maximum<A, B> = <A as Max<B>>::Output`
9292
pub type Maximum<A, B> = <A as Max<B>>::Output;
9393

94-
use type_operators::{IsEqual, IsGreater, IsGreaterOrEqual, IsLess, IsLessOrEqual, IsNotEqual};
94+
use crate::type_operators::{
95+
IsEqual, IsGreater, IsGreaterOrEqual, IsLess, IsLessOrEqual, IsNotEqual,
96+
};
9597
/// Alias for the associated type of `IsLess`: `Le<A, B> = <A as IsLess<B>>::Output`
9698
pub type Le<A, B> = <A as IsLess<B>>::Output;
9799
/// Alias for the associated type of `IsEqual`: `Eq<A, B> = <A as IsEqual<B>>::Output`

0 commit comments

Comments
 (0)