Skip to content

Commit 5bdc3fb

Browse files
committed
Merge #5
5: Add the std feature and release 0.1.36 r=cuviper a=cuviper Fixes #4.
2 parents b22ccfa + e8b8f81 commit 5bdc3fb

File tree

5 files changed

+71
-13
lines changed

5 files changed

+71
-13
lines changed

Cargo.toml

+7-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,13 @@ categories = [ "algorithms", "science" ]
88
license = "MIT/Apache-2.0"
99
repository = "https://github.com/rust-num/num-integer"
1010
name = "num-integer"
11-
version = "0.1.35"
11+
version = "0.1.36"
1212
readme = "README.md"
1313

1414
[dependencies.num-traits]
15-
version = "0.1.32"
15+
version = "0.2.0"
16+
default-features = false
17+
18+
[features]
19+
default = ["std"]
20+
std = []

README.md

+19
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[![crate](https://img.shields.io/crates/v/num-integer.svg)](https://crates.io/crates/num-integer)
44
[![documentation](https://docs.rs/num-integer/badge.svg)](https://docs.rs/num-integer)
5+
![minimum rustc 1.8](https://img.shields.io/badge/rustc-1.8+-red.svg)
56
[![Travis status](https://travis-ci.org/rust-num/num-integer.svg?branch=master)](https://travis-ci.org/rust-num/num-integer)
67

78
`Integer` trait and functions for Rust.
@@ -21,6 +22,24 @@ and this to your crate root:
2122
extern crate num_integer;
2223
```
2324

25+
## Features
26+
27+
This crate can be used without the standard library (`#![no_std]`) by disabling
28+
the default `std` feature. Use this in `Cargo.toml`:
29+
30+
```toml
31+
[dependencies.num-integer]
32+
version = "0.1.36"
33+
default-features = false
34+
```
35+
36+
There is no functional difference with and without `std` at this time, but
37+
there may be in the future.
38+
39+
## Releases
40+
41+
Release notes are available in [RELEASES.md](RELEASES.md).
42+
2443
## Compatibility
2544

2645
The `num-integer` crate is tested for rustc 1.8 and greater.

RELEASES.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Release 0.1.36
2+
3+
- [num-integer now has its own source repository][num-356] at [rust-num/num-integer][home].
4+
- [Corrected the argument order documented in `Integer::is_multiple_of`][1]
5+
- [There is now a `std` feature][5], enabled by default, along with the implication
6+
that building *without* this feature makes this a `#[no_std]` crate.
7+
- There is no difference in the API at this time.
8+
9+
**Contributors**: @cuviper, @jaystrictor
10+
11+
[home]: https://github.com/rust-num/num-integer
12+
[num-356]: https://github.com/rust-num/num/pull/356
13+
[1]: https://github.com/rust-num/num-integer/pull/1
14+
[5]: https://github.com/rust-num/num-integer/pull/5
15+
16+
17+
# Prior releases
18+
19+
No prior release notes were kept. Thanks all the same to the many
20+
contributors that have made this crate what it is!
21+

ci/test_full.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ echo Testing num-integer on rustc ${TRAVIS_RUST_VERSION}
88
cargo build --verbose
99
cargo test --verbose
1010

11-
# We have no features to test...
11+
# test `no_std`
12+
cargo build --verbose --no-default-features
13+
cargo test --verbose --no-default-features

src/lib.rs

+21-10
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,21 @@
99
// except according to those terms.
1010

1111
//! Integer trait and functions.
12+
//!
13+
//! ## Compatibility
14+
//!
15+
//! The `num-integer` crate is tested for rustc 1.8 and greater.
1216
1317
#![doc(html_root_url = "https://docs.rs/num-integer/0.1")]
1418

19+
#![cfg_attr(not(feature = "std"), no_std)]
20+
#[cfg(feature = "std")]
21+
extern crate core;
22+
1523
extern crate num_traits as traits;
1624

17-
use std::ops::Add;
25+
use core::ops::Add;
26+
use core::mem;
1827

1928
use traits::{Num, Signed};
2029

@@ -267,7 +276,7 @@ macro_rules! impl_integer_for_isize {
267276

268277
while m != 0 {
269278
m >>= m.trailing_zeros();
270-
if n > m { ::std::mem::swap(&mut n, &mut m) }
279+
if n > m { mem::swap(&mut n, &mut m) }
271280
m -= n;
272281
}
273282

@@ -312,6 +321,7 @@ macro_rules! impl_integer_for_isize {
312321
#[cfg(test)]
313322
mod $test_mod {
314323
use Integer;
324+
use core::mem;
315325

316326
/// Checks that the division rule holds for:
317327
///
@@ -389,7 +399,7 @@ macro_rules! impl_integer_for_isize {
389399
fn test_gcd_cmp_with_euclidean() {
390400
fn euclidean_gcd(mut m: $T, mut n: $T) -> $T {
391401
while m != 0 {
392-
::std::mem::swap(&mut m, &mut n);
402+
mem::swap(&mut m, &mut n);
393403
m %= n;
394404
}
395405

@@ -526,7 +536,7 @@ macro_rules! impl_integer_for_usize {
526536

527537
while m != 0 {
528538
m >>= m.trailing_zeros();
529-
if n > m { ::std::mem::swap(&mut n, &mut m) }
539+
if n > m { mem::swap(&mut n, &mut m) }
530540
m -= n;
531541
}
532542

@@ -573,6 +583,7 @@ macro_rules! impl_integer_for_usize {
573583
#[cfg(test)]
574584
mod $test_mod {
575585
use Integer;
586+
use core::mem;
576587

577588
#[test]
578589
fn test_div_mod_floor() {
@@ -600,7 +611,7 @@ macro_rules! impl_integer_for_usize {
600611
fn test_gcd_cmp_with_euclidean() {
601612
fn euclidean_gcd(mut m: $T, mut n: $T) -> $T {
602613
while m != 0 {
603-
::std::mem::swap(&mut m, &mut n);
614+
mem::swap(&mut m, &mut n);
604615
m %= n;
605616
}
606617
n
@@ -817,9 +828,10 @@ fn test_iter_binomial() {
817828
macro_rules! check_simple {
818829
($t:ty) => { {
819830
let n: $t = 3;
820-
let c: Vec<_> = IterBinomial::new(n).collect();
821-
let expected = vec![1, 3, 3, 1];
822-
assert_eq!(c, expected);
831+
let expected = [1, 3, 3, 1];
832+
for (b, &e) in IterBinomial::new(n).zip(&expected) {
833+
assert_eq!(b, e);
834+
}
823835
} }
824836
}
825837

@@ -835,9 +847,8 @@ fn test_iter_binomial() {
835847
macro_rules! check_binomial {
836848
($t:ty, $n:expr) => { {
837849
let n: $t = $n;
838-
let c: Vec<_> = IterBinomial::new(n).collect();
839850
let mut k: $t = 0;
840-
for b in c {
851+
for b in IterBinomial::new(n) {
841852
assert_eq!(b, binomial(n, k));
842853
k += 1;
843854
}

0 commit comments

Comments
 (0)