Skip to content

Commit bc50639

Browse files
committed
Update array syntax to conform to RFC 520
Change all instances of the [_, ..n] array syntax to the new [_; n] syntax. See rust-lang/rfcs#520 and rust-lang/rust#19999
1 parent c944634 commit bc50639

11 files changed

Lines changed: 65 additions & 65 deletions

src/crypto/auth_macros.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub const TAGBYTES: uint = $tagbytes;
1414
* When a `Key` goes out of scope its contents
1515
* will be zeroed out
1616
*/
17-
pub struct Key(pub [u8, ..KEYBYTES]);
17+
pub struct Key(pub [u8; KEYBYTES]);
1818

1919
newtype_drop!(Key);
2020
newtype_clone!(Key);
@@ -27,7 +27,7 @@ newtype_impl!(Key, KEYBYTES);
2727
* comparison functions. See `sodiumoxide::crypto::verify::verify_32`
2828
*/
2929
#[deriving(Copy)]
30-
pub struct Tag(pub [u8, ..TAGBYTES]);
30+
pub struct Tag(pub [u8; TAGBYTES]);
3131

3232
impl Eq for Tag {}
3333

@@ -49,7 +49,7 @@ newtype_impl!(Tag, TAGBYTES);
4949
* from sodiumoxide.
5050
*/
5151
pub fn gen_key() -> Key {
52-
let mut k = [0, ..KEYBYTES];
52+
let mut k = [0; KEYBYTES];
5353
randombytes_into(&mut k);
5454
Key(k)
5555
}
@@ -61,7 +61,7 @@ pub fn gen_key() -> Key {
6161
pub fn authenticate(m: &[u8],
6262
&Key(k): &Key) -> Tag {
6363
unsafe {
64-
let mut tag = [0, ..TAGBYTES];
64+
let mut tag = [0; TAGBYTES];
6565
$auth_name(tag.as_mut_ptr(),
6666
m.as_ptr(),
6767
m.len() as c_ulonglong,
@@ -122,7 +122,7 @@ mod bench {
122122
use randombytes::randombytes;
123123
use super::*;
124124

125-
const BENCH_SIZES: [uint, ..14] = [0, 1, 2, 4, 8, 16, 32, 64,
125+
const BENCH_SIZES: [uint; 14] = [0, 1, 2, 4, 8, 16, 32, 64,
126126
128, 256, 512, 1024, 2048, 4096];
127127

128128
#[bench]

src/crypto/curve25519.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub const SCALARBYTES: uint = ffi::crypto_scalarmult_curve25519_SCALARBYTES as u
1515
* `Scalar` value (integer in byte representation)
1616
*/
1717
#[deriving(Copy)]
18-
pub struct Scalar(pub [u8, ..SCALARBYTES]);
18+
pub struct Scalar(pub [u8; SCALARBYTES]);
1919

2020
newtype_clone!(Scalar);
2121
newtype_impl!(Scalar, SCALARBYTES);
@@ -24,7 +24,7 @@ newtype_impl!(Scalar, SCALARBYTES);
2424
* `GroupElement`
2525
*/
2626
#[deriving(Copy)]
27-
pub struct GroupElement(pub [u8, ..BYTES]);
27+
pub struct GroupElement(pub [u8; BYTES]);
2828

2929
newtype_clone!(GroupElement);
3030
newtype_impl!(GroupElement, BYTES);
@@ -36,7 +36,7 @@ newtype_impl!(GroupElement, BYTES);
3636
*/
3737
pub fn scalarmult(&Scalar(n): &Scalar,
3838
&GroupElement(p): &GroupElement) -> GroupElement {
39-
let mut q = [0, ..BYTES];
39+
let mut q = [0; BYTES];
4040
unsafe {
4141
ffi::crypto_scalarmult_curve25519(q.as_mut_ptr(), n.as_ptr(), p.as_ptr());
4242
}
@@ -49,7 +49,7 @@ pub fn scalarmult(&Scalar(n): &Scalar,
4949
* group element `q`/
5050
*/
5151
pub fn scalarmult_base(&Scalar(n): &Scalar) -> GroupElement {
52-
let mut q = [0, ..BYTES];
52+
let mut q = [0; BYTES];
5353
unsafe {
5454
ffi::crypto_scalarmult_curve25519_base(q.as_mut_ptr(), n.as_ptr());
5555
}
@@ -132,8 +132,8 @@ mod bench {
132132

133133
#[bench]
134134
fn bench_scalarmult(b: &mut test::Bencher) {
135-
let mut gbs = [0u8, ..BYTES];
136-
let mut sbs = [0u8, ..SCALARBYTES];
135+
let mut gbs = [0u8; BYTES];
136+
let mut sbs = [0u8; SCALARBYTES];
137137
randombytes_into(&mut gbs);
138138
randombytes_into(&mut sbs);
139139
let g = GroupElement(gbs);
@@ -145,7 +145,7 @@ mod bench {
145145

146146
#[bench]
147147
fn bench_scalarmult_base(b: &mut test::Bencher) {
148-
let mut sbs = [0u8, ..SCALARBYTES];
148+
let mut sbs = [0u8; SCALARBYTES];
149149
randombytes_into(&mut sbs);
150150
let s = Scalar(sbs);
151151
b.iter(|| {

src/crypto/curve25519xsalsa20poly1305.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const BOXZEROBYTES: uint = ffi::crypto_box_curve25519xsalsa20poly1305_BOXZEROBYT
2323
* `PublicKey` for asymmetric authenticated encryption
2424
*/
2525
#[deriving(Copy)]
26-
pub struct PublicKey(pub [u8, ..PUBLICKEYBYTES]);
26+
pub struct PublicKey(pub [u8; PUBLICKEYBYTES]);
2727

2828
newtype_clone!(PublicKey);
2929
newtype_impl!(PublicKey, PUBLICKEYBYTES);
@@ -34,7 +34,7 @@ newtype_impl!(PublicKey, PUBLICKEYBYTES);
3434
* When a `SecretKey` goes out of scope its contents
3535
* will be zeroed out
3636
*/
37-
pub struct SecretKey(pub [u8, ..SECRETKEYBYTES]);
37+
pub struct SecretKey(pub [u8; SECRETKEYBYTES]);
3838

3939
newtype_drop!(SecretKey);
4040
newtype_clone!(SecretKey);
@@ -44,7 +44,7 @@ newtype_impl!(SecretKey, SECRETKEYBYTES);
4444
* `Nonce` for asymmetric authenticated encryption
4545
*/
4646
#[deriving(Copy)]
47-
pub struct Nonce(pub [u8, ..NONCEBYTES]);
47+
pub struct Nonce(pub [u8; NONCEBYTES]);
4848

4949
newtype_clone!(Nonce);
5050
newtype_impl!(Nonce, NONCEBYTES);
@@ -58,8 +58,8 @@ newtype_impl!(Nonce, NONCEBYTES);
5858
*/
5959
pub fn gen_keypair() -> (PublicKey, SecretKey) {
6060
unsafe {
61-
let mut pk = [0u8, ..PUBLICKEYBYTES];
62-
let mut sk = [0u8, ..SECRETKEYBYTES];
61+
let mut pk = [0u8; PUBLICKEYBYTES];
62+
let mut sk = [0u8; SECRETKEYBYTES];
6363
ffi::crypto_box_curve25519xsalsa20poly1305_keypair(
6464
pk.as_mut_ptr(),
6565
sk.as_mut_ptr());
@@ -75,7 +75,7 @@ pub fn gen_keypair() -> (PublicKey, SecretKey) {
7575
* from sodiumoxide.
7676
*/
7777
pub fn gen_nonce() -> Nonce {
78-
let mut n = [0, ..NONCEBYTES];
78+
let mut n = [0; NONCEBYTES];
7979
randombytes_into(&mut n);
8080
Nonce(n)
8181
}
@@ -138,7 +138,7 @@ pub fn open(c: &[u8],
138138
*
139139
* When a `PrecomputedKey` goes out of scope its contents will be zeroed out
140140
*/
141-
pub struct PrecomputedKey([u8, ..PRECOMPUTEDKEYBYTES]);
141+
pub struct PrecomputedKey([u8; PRECOMPUTEDKEYBYTES]);
142142

143143
newtype_drop!(PrecomputedKey);
144144
newtype_clone!(PrecomputedKey);
@@ -150,7 +150,7 @@ newtype_impl!(PrecomputedKey, PRECOMPUTEDKEYBYTES);
150150
*/
151151
pub fn precompute(&PublicKey(pk): &PublicKey,
152152
&SecretKey(sk): &SecretKey) -> PrecomputedKey {
153-
let mut k = [0u8, ..PRECOMPUTEDKEYBYTES];
153+
let mut k = [0u8; PRECOMPUTEDKEYBYTES];
154154
unsafe {
155155
ffi::crypto_box_curve25519xsalsa20poly1305_beforenm(k.as_mut_ptr(),
156156
pk.as_ptr(),
@@ -396,7 +396,7 @@ mod bench {
396396
use randombytes::randombytes;
397397
use super::*;
398398

399-
const BENCH_SIZES: [uint, ..14] = [0, 1, 2, 4, 8, 16, 32, 64,
399+
const BENCH_SIZES: [uint; 14] = [0, 1, 2, 4, 8, 16, 32, 64,
400400
128, 256, 512, 1024, 2048, 4096];
401401

402402
#[bench]

src/crypto/ed25519.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub const SIGNATUREBYTES: uint = ffi::crypto_sign_ed25519_BYTES as uint;
2525
* When a `Seed` goes out of scope its contents
2626
* will be zeroed out
2727
*/
28-
pub struct Seed(pub [u8, ..SEEDBYTES]);
28+
pub struct Seed(pub [u8; SEEDBYTES]);
2929

3030
newtype_drop!(Seed);
3131
newtype_clone!(Seed);
@@ -37,7 +37,7 @@ newtype_impl!(Seed, SEEDBYTES);
3737
* When a `SecretKey` goes out of scope its contents
3838
* will be zeroed out
3939
*/
40-
pub struct SecretKey(pub [u8, ..SECRETKEYBYTES]);
40+
pub struct SecretKey(pub [u8; SECRETKEYBYTES]);
4141

4242
newtype_drop!(SecretKey);
4343
newtype_clone!(SecretKey);
@@ -47,7 +47,7 @@ newtype_impl!(SecretKey, SECRETKEYBYTES);
4747
* `PublicKey` for signatures
4848
*/
4949
#[deriving(Copy)]
50-
pub struct PublicKey(pub [u8, ..PUBLICKEYBYTES]);
50+
pub struct PublicKey(pub [u8; PUBLICKEYBYTES]);
5151

5252
newtype_clone!(PublicKey);
5353
newtype_impl!(PublicKey, PUBLICKEYBYTES);
@@ -62,8 +62,8 @@ newtype_impl!(PublicKey, PUBLICKEYBYTES);
6262
*/
6363
pub fn gen_keypair() -> (PublicKey, SecretKey) {
6464
unsafe {
65-
let mut pk = [0u8, ..PUBLICKEYBYTES];
66-
let mut sk = [0u8, ..SECRETKEYBYTES];
65+
let mut pk = [0u8; PUBLICKEYBYTES];
66+
let mut sk = [0u8; SECRETKEYBYTES];
6767
ffi::crypto_sign_ed25519_keypair(pk.as_mut_ptr(), sk.as_mut_ptr());
6868
(PublicKey(pk), SecretKey(sk))
6969
}
@@ -75,8 +75,8 @@ pub fn gen_keypair() -> (PublicKey, SecretKey) {
7575
*/
7676
pub fn keypair_from_seed(&Seed(seed): &Seed) -> (PublicKey, SecretKey) {
7777
unsafe {
78-
let mut pk = [0u8, ..PUBLICKEYBYTES];
79-
let mut sk = [0u8, ..SECRETKEYBYTES];
78+
let mut pk = [0u8; PUBLICKEYBYTES];
79+
let mut sk = [0u8; SECRETKEYBYTES];
8080
ffi::crypto_sign_ed25519_seed_keypair(pk.as_mut_ptr(),
8181
sk.as_mut_ptr(),
8282
seed.as_ptr());
@@ -158,7 +158,7 @@ fn test_sign_verify_tamper() {
158158
fn test_sign_verify_seed() {
159159
use randombytes::{randombytes, randombytes_into};
160160
for i in range(0, 256u) {
161-
let mut seedbuf = [0, ..32];
161+
let mut seedbuf = [0; 32];
162162
randombytes_into(&mut seedbuf);
163163
let seed = Seed(seedbuf);
164164
let (pk, sk) = keypair_from_seed(&seed);
@@ -173,7 +173,7 @@ fn test_sign_verify_seed() {
173173
fn test_sign_verify_tamper_seed() {
174174
use randombytes::{randombytes, randombytes_into};
175175
for i in range(0, 32u) {
176-
let mut seedbuf = [0, ..32];
176+
let mut seedbuf = [0; 32];
177177
randombytes_into(&mut seedbuf);
178178
let seed = Seed(seedbuf);
179179
let (pk, sk) = keypair_from_seed(&seed);
@@ -211,7 +211,7 @@ fn test_vectors() {
211211
let x3 = x.next().unwrap();
212212
let seed_bytes = x0.slice(0, 64).from_hex().unwrap();
213213
assert!(seed_bytes.len() == SEEDBYTES);
214-
let mut seedbuf = [0u8, ..SEEDBYTES];
214+
let mut seedbuf = [0u8; SEEDBYTES];
215215
for (s, b) in seedbuf.iter_mut().zip(seed_bytes.iter()) {
216216
*s = *b
217217
}
@@ -232,7 +232,7 @@ mod bench {
232232
use randombytes::randombytes;
233233
use super::*;
234234

235-
const BENCH_SIZES: [uint, ..14] = [0, 1, 2, 4, 8, 16, 32, 64,
235+
const BENCH_SIZES: [uint; 14] = [0, 1, 2, 4, 8, 16, 32, 64,
236236
128, 256, 512, 1024, 2048, 4096];
237237

238238
#[bench]

src/crypto/edwards25519sha512batch.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub const SIGNATUREBYTES: uint = ffi::crypto_sign_edwards25519sha512batch_BYTES
1616
* When a `SecretKey` goes out of scope its contents
1717
* will be zeroed out
1818
*/
19-
pub struct SecretKey(pub [u8, ..SECRETKEYBYTES]);
19+
pub struct SecretKey(pub [u8; SECRETKEYBYTES]);
2020

2121
newtype_drop!(SecretKey);
2222
newtype_clone!(SecretKey);
@@ -26,7 +26,7 @@ newtype_impl!(SecretKey, SECRETKEYBYTES);
2626
* `PublicKey` for signatures
2727
*/
2828
#[deriving(Copy)]
29-
pub struct PublicKey(pub [u8, ..PUBLICKEYBYTES]);
29+
pub struct PublicKey(pub [u8; PUBLICKEYBYTES]);
3030

3131
newtype_clone!(PublicKey);
3232
newtype_impl!(PublicKey, PUBLICKEYBYTES);
@@ -41,8 +41,8 @@ newtype_impl!(PublicKey, PUBLICKEYBYTES);
4141
*/
4242
pub fn gen_keypair() -> (PublicKey, SecretKey) {
4343
unsafe {
44-
let mut pk = [0u8, ..PUBLICKEYBYTES];
45-
let mut sk = [0u8, ..SECRETKEYBYTES];
44+
let mut pk = [0u8; PUBLICKEYBYTES];
45+
let mut sk = [0u8; SECRETKEYBYTES];
4646
ffi::crypto_sign_edwards25519sha512batch_keypair(pk.as_mut_ptr(),
4747
sk.as_mut_ptr());
4848
(PublicKey(pk), SecretKey(sk))
@@ -125,7 +125,7 @@ mod bench {
125125
use randombytes::randombytes;
126126
use super::*;
127127

128-
const BENCH_SIZES: [uint, ..14] = [0, 1, 2, 4, 8, 16, 32, 64,
128+
const BENCH_SIZES: [uint; 14] = [0, 1, 2, 4, 8, 16, 32, 64,
129129
128, 256, 512, 1024, 2048, 4096];
130130

131131
#[bench]

src/crypto/hash_macros.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub const BLOCKBYTES: uint = $blockbytes;
88
* Digest-structure
99
*/
1010
#[deriving(Copy)]
11-
pub struct Digest(pub [u8, ..HASHBYTES]);
11+
pub struct Digest(pub [u8; HASHBYTES]);
1212

1313
newtype_clone!(Digest);
1414
newtype_impl!(Digest, HASHBYTES);
@@ -18,7 +18,7 @@ newtype_impl!(Digest, HASHBYTES);
1818
*/
1919
pub fn hash(m: &[u8]) -> Digest {
2020
unsafe {
21-
let mut h = [0, ..HASHBYTES];
21+
let mut h = [0; HASHBYTES];
2222
$hash_name(h.as_mut_ptr(), m.as_ptr(), m.len() as c_ulonglong);
2323
Digest(h)
2424
}
@@ -30,7 +30,7 @@ mod bench {
3030
use randombytes::randombytes;
3131
use super::*;
3232

33-
const BENCH_SIZES: [uint, ..14] = [0, 1, 2, 4, 8, 16, 32, 64,
33+
const BENCH_SIZES: [uint; 14] = [0, 1, 2, 4, 8, 16, 32, 64,
3434
128, 256, 512, 1024, 2048, 4096];
3535

3636
#[bench]

src/crypto/siphash24.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub const KEYBYTES: uint = ffi::crypto_shorthash_siphash24_KEYBYTES as uint;
1414
* Digest-structure
1515
*/
1616
#[deriving(Copy)]
17-
pub struct Digest(pub [u8, ..HASHBYTES]);
17+
pub struct Digest(pub [u8; HASHBYTES]);
1818

1919
newtype_clone!(Digest);
2020
newtype_impl!(Digest, HASHBYTES);
@@ -25,7 +25,7 @@ newtype_impl!(Digest, HASHBYTES);
2525
* When a `Key` goes out of scope its contents
2626
* will be zeroed out
2727
*/
28-
pub struct Key(pub [u8, ..KEYBYTES]);
28+
pub struct Key(pub [u8; KEYBYTES]);
2929

3030
newtype_drop!(Key);
3131
newtype_clone!(Key);
@@ -39,7 +39,7 @@ newtype_impl!(Key, KEYBYTES);
3939
* from sodiumoxide.
4040
*/
4141
pub fn gen_key() -> Key {
42-
let mut k = [0, ..KEYBYTES];
42+
let mut k = [0; KEYBYTES];
4343
randombytes_into(&mut k);
4444
Key(k)
4545
}
@@ -51,7 +51,7 @@ pub fn gen_key() -> Key {
5151
pub fn shorthash(m: &[u8],
5252
&Key(k): &Key) -> Digest {
5353
unsafe {
54-
let mut h = [0, ..HASHBYTES];
54+
let mut h = [0; HASHBYTES];
5555
ffi::crypto_shorthash_siphash24(h.as_mut_ptr(),
5656
m.as_ptr(), m.len() as c_ulonglong,
5757
k.as_ptr());
@@ -143,7 +143,7 @@ mod bench {
143143
use randombytes::randombytes;
144144
use super::*;
145145

146-
const BENCH_SIZES: [uint, ..14] = [0, 1, 2, 4, 8, 16, 32, 64,
146+
const BENCH_SIZES: [uint; 14] = [0, 1, 2, 4, 8, 16, 32, 64,
147147
128, 256, 512, 1024, 2048, 4096];
148148

149149
#[bench]

0 commit comments

Comments
 (0)