Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the std feature and release 0.1.36 #5

Merged
merged 5 commits into from
Feb 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ categories = [ "algorithms", "science" ]
license = "MIT/Apache-2.0"
repository = "https://github.com/rust-num/num-integer"
name = "num-integer"
version = "0.1.35"
version = "0.1.36"
readme = "README.md"

[dependencies.num-traits]
version = "0.1.32"
version = "0.2.0"
default-features = false

[features]
default = ["std"]
std = []
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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

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

## Features

This crate can be used without the standard library (`#![no_std]`) by disabling
the default `std` feature. Use this in `Cargo.toml`:

```toml
[dependencies.num-integer]
version = "0.1.36"
default-features = false
```

There is no functional difference with and without `std` at this time, but
there may be in the future.

## Releases

Release notes are available in [RELEASES.md](RELEASES.md).

## Compatibility

The `num-integer` crate is tested for rustc 1.8 and greater.
21 changes: 21 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Release 0.1.36

- [num-integer now has its own source repository][num-356] at [rust-num/num-integer][home].
- [Corrected the argument order documented in `Integer::is_multiple_of`][1]
- [There is now a `std` feature][5], enabled by default, along with the implication
that building *without* this feature makes this a `#[no_std]` crate.
- There is no difference in the API at this time.

**Contributors**: @cuviper, @jaystrictor

[home]: https://github.com/rust-num/num-integer
[num-356]: https://github.com/rust-num/num/pull/356
[1]: https://github.com/rust-num/num-integer/pull/1
[5]: https://github.com/rust-num/num-integer/pull/5


# Prior releases

No prior release notes were kept. Thanks all the same to the many
contributors that have made this crate what it is!

4 changes: 3 additions & 1 deletion ci/test_full.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ echo Testing num-integer on rustc ${TRAVIS_RUST_VERSION}
cargo build --verbose
cargo test --verbose

# We have no features to test...
# test `no_std`
cargo build --verbose --no-default-features
cargo test --verbose --no-default-features
31 changes: 21 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,21 @@
// except according to those terms.

//! Integer trait and functions.
//!
//! ## Compatibility
//!
//! The `num-integer` crate is tested for rustc 1.8 and greater.

#![doc(html_root_url = "https://docs.rs/num-integer/0.1")]

#![cfg_attr(not(feature = "std"), no_std)]
#[cfg(feature = "std")]
extern crate core;

extern crate num_traits as traits;

use std::ops::Add;
use core::ops::Add;
use core::mem;

use traits::{Num, Signed};

Expand Down Expand Up @@ -267,7 +276,7 @@ macro_rules! impl_integer_for_isize {

while m != 0 {
m >>= m.trailing_zeros();
if n > m { ::std::mem::swap(&mut n, &mut m) }
if n > m { mem::swap(&mut n, &mut m) }
m -= n;
}

Expand Down Expand Up @@ -312,6 +321,7 @@ macro_rules! impl_integer_for_isize {
#[cfg(test)]
mod $test_mod {
use Integer;
use core::mem;

/// Checks that the division rule holds for:
///
Expand Down Expand Up @@ -389,7 +399,7 @@ macro_rules! impl_integer_for_isize {
fn test_gcd_cmp_with_euclidean() {
fn euclidean_gcd(mut m: $T, mut n: $T) -> $T {
while m != 0 {
::std::mem::swap(&mut m, &mut n);
mem::swap(&mut m, &mut n);
m %= n;
}

Expand Down Expand Up @@ -526,7 +536,7 @@ macro_rules! impl_integer_for_usize {

while m != 0 {
m >>= m.trailing_zeros();
if n > m { ::std::mem::swap(&mut n, &mut m) }
if n > m { mem::swap(&mut n, &mut m) }
m -= n;
}

Expand Down Expand Up @@ -573,6 +583,7 @@ macro_rules! impl_integer_for_usize {
#[cfg(test)]
mod $test_mod {
use Integer;
use core::mem;

#[test]
fn test_div_mod_floor() {
Expand Down Expand Up @@ -600,7 +611,7 @@ macro_rules! impl_integer_for_usize {
fn test_gcd_cmp_with_euclidean() {
fn euclidean_gcd(mut m: $T, mut n: $T) -> $T {
while m != 0 {
::std::mem::swap(&mut m, &mut n);
mem::swap(&mut m, &mut n);
m %= n;
}
n
Expand Down Expand Up @@ -817,9 +828,10 @@ fn test_iter_binomial() {
macro_rules! check_simple {
($t:ty) => { {
let n: $t = 3;
let c: Vec<_> = IterBinomial::new(n).collect();
let expected = vec![1, 3, 3, 1];
assert_eq!(c, expected);
let expected = [1, 3, 3, 1];
for (b, &e) in IterBinomial::new(n).zip(&expected) {
assert_eq!(b, e);
}
} }
}

Expand All @@ -835,9 +847,8 @@ fn test_iter_binomial() {
macro_rules! check_binomial {
($t:ty, $n:expr) => { {
let n: $t = $n;
let c: Vec<_> = IterBinomial::new(n).collect();
let mut k: $t = 0;
for b in c {
for b in IterBinomial::new(n) {
assert_eq!(b, binomial(n, k));
k += 1;
}
Expand Down