Skip to content

Commit 9f1d7fa

Browse files
plotskogwqtonychain
authored andcommitted
Switch from libcollections to liballoc (gated on an "alloc" feature)
libcollections was recently merged into liballoc: rust-lang/rust#42648 I went ahead and also added an "alloc" feature which no_std users can use to opt into liballoc features (i.e. any code using Vec). This should have no effect on anything but no_std usage. It does make it possible for people without allocators to use curve25519-dalek if they want though. Might be nice for "bare metal" development. All that said, from what I can gather liballoc, while not "stable", should likely stick around for the forseeable future. Some backstory on the liballoc/libcollections merge here: rust-lang/rust#42565
1 parent e879869 commit 9f1d7fa

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

.travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ matrix:
3737
env: TEST_COMMAND=build EXTRA_FLAGS=--no-default-features FEATURES=''
3838
- rust: beta
3939
env: TEST_COMMAND=build EXTRA_FLAGS=--no-default-features FEATURES=''
40+
- rust: nightly
41+
env: TEST_COMMAND=build EXTRA_FLAGS=--no-default-features FEATURES='alloc'
4042

4143
script:
4244
- cargo $TEST_COMMAND --features="$FEATURES" $EXTRA_FLAGS

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ version = "0.6"
4646
nightly = ["radix_51"]
4747
default = ["std"]
4848
std = ["rand"]
49+
alloc = []
4950
yolocrypto = []
5051
bench = []
5152
# Radix-51 arithmetic using u128

src/curve.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@
7777
// affine and projective cakes and eat both of them too.
7878
#![allow(non_snake_case)]
7979

80-
#[cfg(not(feature = "std"))]
81-
use collections::Vec;
80+
#[cfg(feature = "alloc")]
81+
use alloc::Vec;
8282

8383
use core::fmt::Debug;
8484
use core::iter::Iterator;
@@ -1195,6 +1195,7 @@ pub mod vartime {
11951195
///
11961196
/// A vector of `Scalar`s and a vector of `ExtendedPoints`. It is an
11971197
/// error to call this function with two vectors of different lengths.
1198+
#[cfg(any(feature = "alloc", feature = "std"))]
11981199
pub fn k_fold_scalar_mult<'a,'b,I,J>(scalars: I, points: J) -> ExtendedPoint
11991200
where I: IntoIterator<Item=&'a Scalar>, J: IntoIterator<Item=&'b ExtendedPoint>
12001201
{

src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// - Henry de Valence <[email protected]>
1111

1212
#![cfg_attr(not(feature = "std"), no_std)]
13-
#![cfg_attr(not(feature = "std"), feature(collections))]
13+
#![cfg_attr(feature = "alloc", feature(alloc))]
1414
#![cfg_attr(feature = "nightly", feature(i128_type))]
1515
#![cfg_attr(feature = "bench", feature(test))]
1616

@@ -58,8 +58,8 @@ extern crate core;
5858
#[cfg(feature = "std")]
5959
extern crate rand;
6060

61-
#[cfg(not(feature = "std"))]
62-
extern crate collections;
61+
#[cfg(feature = "alloc")]
62+
extern crate alloc;
6363

6464
// Modules for low-level operations directly on field elements and curve points.
6565

0 commit comments

Comments
 (0)