same type. By default, arrays are immutable.
```{rust}
-let a = [1i, 2i, 3i]; // a: [int, ..3]
-let mut m = [1i, 2i, 3i]; // mut m: [int, ..3]
+let a = [1i, 2i, 3i]; // a: [int; 3]
+let mut m = [1i, 2i, 3i]; // mut m: [int; 3]
```
There's a shorthand for initializing each element of an array to the same
value. In this example, each element of `a` will be initialized to `0i`:
```{rust}
-let a = [0i, ..20]; // a: [int, ..20]
+let a = [0i; 20]; // a: [int; 20]
```
Arrays have type `[T,..N]`. We'll talk about this `T` notation later, when we
const BIT1: uint = 1 << 0;
const BIT2: uint = 1 << 1;
-const BITS: [uint, ..2] = [BIT1, BIT2];
+const BITS: [uint; 2] = [BIT1, BIT2];
const STRING: &'static str = "bitstring";
struct BitsNStrings<'a> {
- mybits: [uint, ..2],
+ mybits: [uint; 2],
mystring: &'a str
}
```
[1i, 2, 3, 4];
["a", "b", "c", "d"];
-[0i, ..128]; // array with 128 zeros
+[0i; 128]; // array with 128 zeros
[0u8, 0u8, 0u8, 0u8];
```
```{rust}
let vec: Vec<int> = vec![1, 2, 3];
-let arr: [int, ..3] = [1, 2, 3];
+let arr: [int; 3] = [1, 2, 3];
let s: &[int] = vec.as_slice();
```
#[bench]
fn bench_collect_into(b: &mut test::Bencher) {
- let v = &[0i, ..64];
+ let v = &[0i; 64];
b.iter(|| {
let _: DList<int> = v.iter().map(|x| *x).collect();
})
#[bench]
fn bench_iter(b: &mut test::Bencher) {
- let v = &[0i, ..128];
+ let v = &[0i; 128];
let m: DList<int> = v.iter().map(|&x|x).collect();
b.iter(|| {
assert!(m.iter().count() == 128);
}
#[bench]
fn bench_iter_mut(b: &mut test::Bencher) {
- let v = &[0i, ..128];
+ let v = &[0i; 128];
let mut m: DList<int> = v.iter().map(|&x|x).collect();
b.iter(|| {
assert!(m.iter_mut().count() == 128);
}
#[bench]
fn bench_iter_rev(b: &mut test::Bencher) {
- let v = &[0i, ..128];
+ let v = &[0i; 128];
let m: DList<int> = v.iter().map(|&x|x).collect();
b.iter(|| {
assert!(m.iter().rev().count() == 128);
}
#[bench]
fn bench_iter_mut_rev(b: &mut test::Bencher) {
- let v = &[0i, ..128];
+ let v = &[0i; 128];
let mut m: DList<int> = v.iter().map(|&x|x).collect();
b.iter(|| {
assert!(m.iter_mut().rev().count() == 128);
fn clone_from_slice(&mut self, &[T]) -> uint;
}
+
#[unstable = "trait is unstable"]
impl<T: Clone> CloneSliceExt<T> for [T] {
/// Returns a copy of `v`.
#[test]
fn test_is_empty() {
- let xs: [int, ..0] = [];
+ let xs: [int; 0] = [];
assert!(xs.is_empty());
assert!(![0i].is_empty());
}
#[test]
fn test_len_divzero() {
- type Z = [i8, ..0];
+ type Z = [i8; 0];
let v0 : &[Z] = &[];
let v1 : &[Z] = &[[]];
let v2 : &[Z] = &[[], []];
#[test]
fn test_permutations() {
{
- let v: [int, ..0] = [];
+ let v: [int; 0] = [];
let mut it = v.permutations();
let (min_size, max_opt) = it.size_hint();
assert_eq!(min_size, 1);
#[test]
fn test_concat() {
- let v: [Vec<int>, ..0] = [];
+ let v: [Vec<int>; 0] = [];
let c: Vec<int> = v.concat();
assert_eq!(c, []);
let d: Vec<int> = [vec![1i], vec![2i,3i]].concat();
assert_eq!(d, vec![1i, 2, 3]);
- let v: [&[int], ..2] = [&[1], &[2, 3]];
+ let v: [&[int]; 2] = [&[1], &[2, 3]];
assert_eq!(v.connect(&0), vec![1i, 0, 2, 3]);
- let v: [&[int], ..3] = [&[1i], &[2], &[3]];
+ let v: [&[int]; 3] = [&[1i], &[2], &[3]];
assert_eq!(v.connect(&0), vec![1i, 0, 2, 0, 3]);
}
#[test]
fn test_connect() {
- let v: [Vec<int>, ..0] = [];
+ let v: [Vec<int>; 0] = [];
assert_eq!(v.connect_vec(&0), vec![]);
assert_eq!([vec![1i], vec![2i, 3]].connect_vec(&0), vec![1, 0, 2, 3]);
assert_eq!([vec![1i], vec![2i], vec![3i]].connect_vec(&0), vec![1, 0, 2, 0, 3]);
- let v: [&[int], ..2] = [&[1], &[2, 3]];
+ let v: [&[int]; 2] = [&[1], &[2, 3]];
assert_eq!(v.connect_vec(&0), vec![1, 0, 2, 3]);
- let v: [&[int], ..3] = [&[1], &[2], &[3]];
+ let v: [&[int]; 3] = [&[1], &[2], &[3]];
assert_eq!(v.connect_vec(&0), vec![1, 0, 2, 0, 3]);
}
}
assert_eq!(cnt, 11);
- let xs: [Foo, ..3] = [Foo, Foo, Foo];
+ let xs: [Foo; 3] = [Foo, Foo, Foo];
cnt = 0;
for f in xs.iter() {
assert!(*f == Foo);
#[test]
fn test_chars_decoding() {
- let mut bytes = [0u8, ..4];
+ let mut bytes = [0u8; 4];
for c in range(0u32, 0x110000).filter_map(|c| ::core::char::from_u32(c)) {
let len = c.encode_utf8(&mut bytes).unwrap_or(0);
let s = ::core::str::from_utf8(bytes[..len]).unwrap();
#[test]
fn test_chars_rev_decoding() {
- let mut bytes = [0u8, ..4];
+ let mut bytes = [0u8; 4];
for c in range(0u32, 0x110000).filter_map(|c| ::core::char::from_u32(c)) {
let len = c.encode_utf8(&mut bytes).unwrap_or(0);
let s = ::core::str::from_utf8(bytes[..len]).unwrap();
assert!(idx <= len);
assert!(self.is_char_boundary(idx));
self.vec.reserve(4);
- let mut bits = [0, ..4];
+ let mut bits = [0; 4];
let amt = ch.encode_utf8(&mut bits).unwrap();
unsafe {
// For an f64 the exponent is in the range of [-1022, 1023] for base 2, so
// we may have up to that many digits. Give ourselves some extra wiggle room
// otherwise as well.
- let mut buf = [0u8, ..1536];
+ let mut buf = [0u8; 1536];
let mut end = 0;
let radix_gen: T = cast(radix as int).unwrap();
// Writes the sign if it exists, and then the prefix if it was requested
let write_prefix = |&: f: &mut Formatter| {
for c in sign.into_iter() {
- let mut b = [0, ..4];
+ let mut b = [0; 4];
let n = c.encode_utf8(&mut b).unwrap_or(0);
try!(f.buf.write(b[..n]));
}
rt::AlignCenter => (padding / 2, (padding + 1) / 2),
};
- let mut fill = [0u8, ..4];
+ let mut fill = [0u8; 4];
let len = self.fill.encode_utf8(&mut fill).unwrap_or(0);
for _ in range(0, pre_pad) {
fn fmt(&self, f: &mut Formatter) -> Result {
use char::Char;
- let mut utf8 = [0u8, ..4];
+ let mut utf8 = [0u8; 4];
let amt = self.encode_utf8(&mut utf8).unwrap_or(0);
let s: &str = unsafe { mem::transmute(utf8[..amt]) };
Show::fmt(s, f)
// characters for a base 2 number.
let zero = Int::zero();
let is_positive = x >= zero;
- let mut buf = [0u8, ..64];
+ let mut buf = [0u8; 64];
let mut curr = buf.len();
let base = cast(self.base()).unwrap();
if is_positive {
#[test]
#[allow(unused_must_use)]
fn test_siphash() {
- let vecs : [[u8, ..8], ..64] = [
+ let vecs : [[u8; 8]; 64] = [
[ 0x31, 0x0e, 0x0e, 0xdd, 0x47, 0xdb, 0x6f, 0x72, ],
[ 0xfd, 0x67, 0xdc, 0x93, 0xc5, 0x39, 0xf8, 0x74, ],
[ 0x5a, 0x4f, 0xa9, 0xd9, 0x09, 0x80, 0x6c, 0x0d, ],
let mut state_inc = SipState::new_with_keys(k0, k1);
let mut state_full = SipState::new_with_keys(k0, k1);
- fn to_hex_str(r: &[u8, ..8]) -> String {
+ fn to_hex_str(r: &[u8; 8]) -> String {
let mut s = String::new();
for b in r.iter() {
s.push_str(format!("{}", fmt::radix(*b, 16)).as_slice());
/// ```rust
/// use std::iter::{NoElements, OneElement, MinMax};
///
- /// let v: [int, ..0] = [];
+ /// let v: [int; 0] = [];
/// assert_eq!(v.iter().min_max(), NoElements);
///
/// let v = [1i];
}
// https://tools.ietf.org/html/rfc3629
-static UTF8_CHAR_WIDTH: [u8, ..256] = [
+static UTF8_CHAR_WIDTH: [u8; 256] = [
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x1F
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
#[test]
fn any_fixed_vec() {
- let test = [0u, ..8];
+ let test = [0u; 8];
let test = &test as &Any;
- assert!(test.is::<[uint, ..8]>());
- assert!(!test.is::<[uint, ..10]>());
+ assert!(test.is::<[uint; 8]>());
+ assert!(!test.is::<[uint; 10]>());
}
#[test]
fn test_encode_utf8() {
fn check(input: char, expect: &[u8]) {
- let mut buf = [0u8, ..4];
+ let mut buf = [0u8; 4];
let n = input.encode_utf8(buf.as_mut_slice()).unwrap_or(0);
assert_eq!(buf[..n], expect);
}
#[test]
fn test_encode_utf16() {
fn check(input: char, expect: &[u16]) {
- let mut buf = [0u16, ..2];
+ let mut buf = [0u16; 2];
let n = input.encode_utf16(buf.as_mut_slice()).unwrap_or(0);
assert_eq!(buf[..n], expect);
}
#[test]
#[allow(unused_must_use)]
fn test_siphash() {
- let vecs : [[u8, ..8], ..64] = [
+ let vecs : [[u8; 8]; 64] = [
[ 0x31, 0x0e, 0x0e, 0xdd, 0x47, 0xdb, 0x6f, 0x72, ],
[ 0xfd, 0x67, 0xdc, 0x93, 0xc5, 0x39, 0xf8, 0x74, ],
[ 0x5a, 0x4f, 0xa9, 0xd9, 0x09, 0x80, 0x6c, 0x0d, ],
let mut state_inc = SipState::new_with_keys(k0, k1);
let mut state_full = SipState::new_with_keys(k0, k1);
- fn to_hex_str(r: &[u8, ..8]) -> String {
+ fn to_hex_str(r: &[u8; 8]) -> String {
let mut s = String::new();
for b in r.iter() {
s.push_str(format!("{}", fmt::radix(*b, 16)).as_slice());
#[test]
fn test_lt() {
- let empty: [int, ..0] = [];
+ let empty: [int; 0] = [];
let xs = [1i,2,3];
let ys = [1i,2,0];
#[test]
fn test_min_max() {
- let v: [int, ..0] = [];
+ let v: [int; 0] = [];
assert_eq!(v.iter().min_max(), NoElements);
let v = [1i];
#[test]
fn test_set_memory() {
- let mut xs = [0u8, ..20];
+ let mut xs = [0u8; 20];
let ptr = xs.as_mut_ptr();
unsafe { set_memory(ptr, 5u8, xs.len()); }
- assert!(xs == [5u8, ..20]);
+ assert!(xs == [5u8; 20]);
}
#[repr(C)]
#[deriving(Copy)] pub struct sockaddr {
pub sa_family: sa_family_t,
- pub sa_data: [u8, ..14],
+ pub sa_data: [u8; 14],
}
#[repr(C)]
#[deriving(Copy)] pub struct sockaddr_storage {
pub ss_family: sa_family_t,
pub __ss_align: i64,
- pub __ss_pad2: [u8, ..112],
+ pub __ss_pad2: [u8; 112],
}
#[repr(C)]
#[deriving(Copy)] pub struct sockaddr_in {
pub sin_family: sa_family_t,
pub sin_port: in_port_t,
pub sin_addr: in_addr,
- pub sin_zero: [u8, ..8],
+ pub sin_zero: [u8; 8],
}
#[repr(C)]
#[deriving(Copy)] pub struct in_addr {
}
#[repr(C)]
#[deriving(Copy)] pub struct in6_addr {
- pub s6_addr: [u16, ..8]
+ pub s6_addr: [u16; 8]
}
#[repr(C)]
#[deriving(Copy)] pub struct ip_mreq {
#[repr(C)]
#[deriving(Copy)] pub struct sockaddr_un {
pub sun_family: sa_family_t,
- pub sun_path: [c_char, ..108]
+ pub sun_path: [c_char; 108]
}
#[repr(C)]
#[repr(C)]
#[deriving(Copy)] pub struct pthread_attr_t {
- pub __size: [u32, ..9]
+ pub __size: [u32; 9]
}
}
#[cfg(target_arch = "arm")]
#[repr(C)]
#[deriving(Copy)] pub struct stat {
pub st_dev: c_ulonglong,
- pub __pad0: [c_uchar, ..4],
+ pub __pad0: [c_uchar; 4],
pub __st_ino: ino_t,
pub st_mode: c_uint,
pub st_nlink: c_uint,
pub st_uid: uid_t,
pub st_gid: gid_t,
pub st_rdev: c_ulonglong,
- pub __pad3: [c_uchar, ..4],
+ pub __pad3: [c_uchar; 4],
pub st_size: c_longlong,
pub st_blksize: blksize_t,
pub st_blocks: c_ulonglong,
#[repr(C)]
#[deriving(Copy)] pub struct pthread_attr_t {
- pub __size: [u32, ..9]
+ pub __size: [u32; 9]
}
}
#[cfg(any(target_arch = "mips", target_arch = "mipsel"))]
#[repr(C)]
#[deriving(Copy)] pub struct stat {
pub st_dev: c_ulong,
- pub st_pad1: [c_long, ..3],
+ pub st_pad1: [c_long; 3],
pub st_ino: ino_t,
pub st_mode: mode_t,
pub st_nlink: nlink_t,
pub st_uid: uid_t,
pub st_gid: gid_t,
pub st_rdev: c_ulong,
- pub st_pad2: [c_long, ..2],
+ pub st_pad2: [c_long; 2],
pub st_size: off_t,
pub st_pad3: c_long,
pub st_atime: time_t,
pub st_ctime_nsec: c_long,
pub st_blksize: blksize_t,
pub st_blocks: blkcnt_t,
- pub st_pad5: [c_long, ..14],
+ pub st_pad5: [c_long; 14],
}
#[repr(C)]
#[repr(C)]
#[deriving(Copy)] pub struct pthread_attr_t {
- pub __size: [u32, ..9]
+ pub __size: [u32; 9]
}
}
pub mod posix08 {}
pub sll_hatype: c_ushort,
pub sll_pkttype: c_uchar,
pub sll_halen: c_uchar,
- pub sll_addr: [c_uchar, ..8]
+ pub sll_addr: [c_uchar; 8]
}
}
pub st_mtime_nsec: c_long,
pub st_ctime: time_t,
pub st_ctime_nsec: c_long,
- pub __unused: [c_long, ..3],
+ pub __unused: [c_long; 3],
}
#[repr(C)]
#[repr(C)]
#[deriving(Copy)] pub struct pthread_attr_t {
- pub __size: [u64, ..7]
+ pub __size: [u64; 7]
}
}
pub mod posix08 {
pub sll_hatype: c_ushort,
pub sll_pkttype: c_uchar,
pub sll_halen: c_uchar,
- pub sll_addr: [c_uchar, ..8]
+ pub sll_addr: [c_uchar; 8]
}
}
#[deriving(Copy)] pub struct sockaddr {
pub sa_len: u8,
pub sa_family: sa_family_t,
- pub sa_data: [u8, ..14],
+ pub sa_data: [u8; 14],
}
#[repr(C)]
#[deriving(Copy)] pub struct sockaddr_storage {
pub ss_len: u8,
pub ss_family: sa_family_t,
- pub __ss_pad1: [u8, ..6],
+ pub __ss_pad1: [u8; 6],
pub __ss_align: i64,
- pub __ss_pad2: [u8, ..112],
+ pub __ss_pad2: [u8; 112],
}
#[repr(C)]
#[deriving(Copy)] pub struct sockaddr_in {
pub sin_family: sa_family_t,
pub sin_port: in_port_t,
pub sin_addr: in_addr,
- pub sin_zero: [u8, ..8],
+ pub sin_zero: [u8; 8],
}
#[repr(C)]
#[deriving(Copy)] pub struct in_addr {
}
#[repr(C)]
#[deriving(Copy)] pub struct in6_addr {
- pub s6_addr: [u16, ..8]
+ pub s6_addr: [u16; 8]
}
#[repr(C)]
#[deriving(Copy)] pub struct ip_mreq {
#[deriving(Copy)] pub struct sockaddr_un {
pub sun_len: u8,
pub sun_family: sa_family_t,
- pub sun_path: [c_char, ..104]
+ pub sun_path: [c_char; 104]
}
#[repr(C)]
#[deriving(Copy)] pub struct ifaddrs {
pub st_lspare: int32_t,
pub st_birthtime: time_t,
pub st_birthtime_nsec: c_long,
- pub __unused: [uint8_t, ..2],
+ pub __unused: [uint8_t; 2],
}
#[repr(C)]
#[deriving(Copy)] pub struct sockaddr {
pub sa_len: u8,
pub sa_family: sa_family_t,
- pub sa_data: [u8, ..14],
+ pub sa_data: [u8; 14],
}
#[repr(C)]
#[deriving(Copy)] pub struct sockaddr_storage {
pub ss_len: u8,
pub ss_family: sa_family_t,
- pub __ss_pad1: [u8, ..6],
+ pub __ss_pad1: [u8; 6],
pub __ss_align: i64,
- pub __ss_pad2: [u8, ..112],
+ pub __ss_pad2: [u8; 112],
}
#[repr(C)]
#[deriving(Copy)] pub struct sockaddr_in {
pub sin_family: sa_family_t,
pub sin_port: in_port_t,
pub sin_addr: in_addr,
- pub sin_zero: [u8, ..8],
+ pub sin_zero: [u8; 8],
}
#[repr(C)]
#[deriving(Copy)] pub struct in_addr {
}
#[repr(C)]
#[deriving(Copy)] pub struct in6_addr {
- pub s6_addr: [u16, ..8]
+ pub s6_addr: [u16; 8]
}
#[repr(C)]
#[deriving(Copy)] pub struct ip_mreq {
#[deriving(Copy)] pub struct sockaddr_un {
pub sun_len: u8,
pub sun_family: sa_family_t,
- pub sun_path: [c_char, ..104]
+ pub sun_path: [c_char; 104]
}
#[repr(C)]
#[deriving(Copy)] pub struct ifaddrs {
#[repr(C)]
#[deriving(Copy)] pub struct sockaddr {
pub sa_family: sa_family_t,
- pub sa_data: [u8, ..14],
+ pub sa_data: [u8; 14],
}
#[repr(C)]
#[deriving(Copy)] pub struct sockaddr_storage {
pub ss_family: sa_family_t,
- pub __ss_pad1: [u8, ..6],
+ pub __ss_pad1: [u8; 6],
pub __ss_align: i64,
- pub __ss_pad2: [u8, ..112],
+ pub __ss_pad2: [u8; 112],
}
#[repr(C)]
#[deriving(Copy)] pub struct sockaddr_in {
pub sin_family: sa_family_t,
pub sin_port: in_port_t,
pub sin_addr: in_addr,
- pub sin_zero: [u8, ..8],
+ pub sin_zero: [u8; 8],
}
#[repr(C)]
#[deriving(Copy)] pub struct in_addr {
}
#[repr(C)]
#[deriving(Copy)] pub struct in6_addr {
- pub s6_addr: [u16, ..8]
+ pub s6_addr: [u16; 8]
}
#[repr(C)]
#[deriving(Copy)] pub struct ip_mreq {
#[repr(C)]
#[deriving(Copy)] pub struct sockaddr_un {
pub sun_family: sa_family_t,
- pub sun_path: [c_char, ..108]
+ pub sun_path: [c_char; 108]
}
}
}
pub Data1: DWORD,
pub Data2: WORD,
pub Data3: WORD,
- pub Data4: [BYTE, ..8],
+ pub Data4: [BYTE; 8],
}
#[repr(C)]
pub nFileSizeLow: DWORD,
pub dwReserved0: DWORD,
pub dwReserved1: DWORD,
- pub cFileName: [wchar_t, ..260], // #define MAX_PATH 260
- pub cAlternateFileName: [wchar_t, ..14],
+ pub cFileName: [wchar_t; 260], // #define MAX_PATH 260
+ pub cAlternateFileName: [wchar_t; 14],
}
pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW;
#[deriving(Copy)] pub struct sockaddr {
pub sa_len: u8,
pub sa_family: sa_family_t,
- pub sa_data: [u8, ..14],
+ pub sa_data: [u8; 14],
}
#[repr(C)]
#[deriving(Copy)] pub struct sockaddr_storage {
pub ss_len: u8,
pub ss_family: sa_family_t,
- pub __ss_pad1: [u8, ..6],
+ pub __ss_pad1: [u8; 6],
pub __ss_align: i64,
- pub __ss_pad2: [u8, ..112],
+ pub __ss_pad2: [u8; 112],
}
#[repr(C)]
pub sin_family: sa_family_t,
pub sin_port: in_port_t,
pub sin_addr: in_addr,
- pub sin_zero: [u8, ..8],
+ pub sin_zero: [u8; 8],
}
#[repr(C)]
#[repr(C)]
#[deriving(Copy)] pub struct in6_addr {
- pub s6_addr: [u16, ..8]
+ pub s6_addr: [u16; 8]
}
#[repr(C)]
#[deriving(Copy)] pub struct sockaddr_un {
pub sun_len: u8,
pub sun_family: sa_family_t,
- pub sun_path: [c_char, ..104]
+ pub sun_path: [c_char; 104]
}
#[repr(C)]
pub st_flags: uint32_t,
pub st_gen: uint32_t,
pub st_lspare: int32_t,
- pub st_qspare: [int64_t, ..2],
+ pub st_qspare: [int64_t; 2],
}
#[repr(C)]
#[repr(C)]
#[deriving(Copy)] pub struct pthread_attr_t {
pub __sig: c_long,
- pub __opaque: [c_char, ..36]
+ pub __opaque: [c_char; 36]
}
}
pub mod posix08 {
pub st_flags: uint32_t,
pub st_gen: uint32_t,
pub st_lspare: int32_t,
- pub st_qspare: [int64_t, ..2],
+ pub st_qspare: [int64_t; 2],
}
#[repr(C)]
#[repr(C)]
#[deriving(Copy)] pub struct pthread_attr_t {
pub __sig: c_long,
- pub __opaque: [c_char, ..56]
+ pub __opaque: [c_char; 56]
}
}
pub mod posix08 {
pub level: u32,
}
-pub static LOG_LEVEL_NAMES: [&'static str, ..4] = ["ERROR", "WARN", "INFO",
+pub static LOG_LEVEL_NAMES: [&'static str; 4] = ["ERROR", "WARN", "INFO",
"DEBUG"];
/// Parse an individual log level that is either a number or a symbolic log level
fn test_rng_true_values() {
// Test vectors 1 and 2 from
// http://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04
- let seed : &[_] = &[0u32, ..8];
+ let seed : &[_] = &[0u32; 8];
let mut ra: ChaChaRng = SeedableRng::from_seed(seed);
let v = Vec::from_fn(16, |_| ra.next_u32());
// the most significant bit is set, the second most significant bit is set etc. we can
// replace up to three "and+branch" with a single table lookup which gives us a measured
// speedup of around 2x on x86_64.
- static SHIFT_MASK_TABLE: [(uint, u32), ..16] = [
+ static SHIFT_MASK_TABLE: [(uint, u32); 16] = [
(0, 0x0), (0, 0x0fffffff),
(8, 0x1fffff), (8, 0x1fffff),
(16, 0x3fff), (16, 0x3fff), (16, 0x3fff), (16, 0x3fff),
// Note: We declare here that the borrow
// occurs upon entering the `[...]`
// pattern. This implies that something like
- // `[a, ..b]` where `a` is a move is illegal,
+ // `[a; b]` where `a` is a move is illegal,
// because the borrow is already in effect.
// In fact such a move would be safe-ish, but
// it effectively *requires* that we use the
}
pub struct Node<N> {
- first_edge: [EdgeIndex, ..2], // see module comment
+ first_edge: [EdgeIndex; 2], // see module comment
pub data: N,
}
pub struct Edge<E> {
- next_edge: [EdgeIndex, ..2], // see module comment
+ next_edge: [EdgeIndex; 2], // see module comment
source: NodeIndex,
target: NodeIndex,
pub data: E,
}
impl ParamSpace {
- pub fn all() -> [ParamSpace, ..3] {
+ pub fn all() -> [ParamSpace; 3] {
[TypeSpace, SelfSpace, FnSpace]
}
/// A FixedBuffer of 64 bytes useful for implementing Sha256 which has a 64 byte blocksize.
struct FixedBuffer64 {
- buffer: [u8, ..64],
+ buffer: [u8; 64],
buffer_idx: uint,
}
/// Create a new FixedBuffer64
fn new() -> FixedBuffer64 {
return FixedBuffer64 {
- buffer: [0u8, ..64],
+ buffer: [0u8; 64],
buffer_idx: 0
};
}
}
impl Engine256State {
- fn new(h: &[u32, ..8]) -> Engine256State {
+ fn new(h: &[u32; 8]) -> Engine256State {
return Engine256State {
h0: h[0],
h1: h[1],
};
}
- fn reset(&mut self, h: &[u32, ..8]) {
+ fn reset(&mut self, h: &[u32; 8]) {
self.h0 = h[0];
self.h1 = h[1];
self.h2 = h[2];
let mut g = self.h6;
let mut h = self.h7;
- let mut w = [0u32, ..64];
+ let mut w = [0u32; 64];
// Sha-512 and Sha-256 use basically the same calculations which are implemented
// by these macros. Inlining the calculations seems to result in better generated code.
}
}
-static K32: [u32, ..64] = [
+static K32: [u32; 64] = [
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
}
impl Engine256 {
- fn new(h: &[u32, ..8]) -> Engine256 {
+ fn new(h: &[u32; 8]) -> Engine256 {
return Engine256 {
length_bits: 0,
buffer: FixedBuffer64::new(),
}
}
- fn reset(&mut self, h: &[u32, ..8]) {
+ fn reset(&mut self, h: &[u32; 8]) {
self.length_bits = 0;
self.buffer.reset();
self.state.reset(h);
fn output_bits(&self) -> uint { 256 }
}
-static H256: [u32, ..8] = [
+static H256: [u32; 8] = [
0x6a09e667,
0xbb67ae85,
0x3c6ef372,
#[bench]
pub fn sha256_10(b: &mut Bencher) {
let mut sh = Sha256::new();
- let bytes = [1u8, ..10];
+ let bytes = [1u8; 10];
b.iter(|| {
sh.input(&bytes);
});
#[bench]
pub fn sha256_1k(b: &mut Bencher) {
let mut sh = Sha256::new();
- let bytes = [1u8, ..1024];
+ let bytes = [1u8; 1024];
b.iter(|| {
sh.input(&bytes);
});
#[bench]
pub fn sha256_64k(b: &mut Bencher) {
let mut sh = Sha256::new();
- let bytes = [1u8, ..65536];
+ let bytes = [1u8; 65536];
b.iter(|| {
sh.input(&bytes);
});
//! the following:
//!
//! ```rust
-//! fn foo(a: [D, ..10], i: uint) -> D {
+//! fn foo(a: [D; 10], i: uint) -> D {
//! a[i]
//! }
//! ```
//! would arise is the following:
//!
//! ```rust
-//! fn foo(a: [D, ..10], b: [D, ..10], i: uint, t: bool) -> D {
+//! fn foo(a: [D; 10], b: [D; 10], i: uint, t: bool) -> D {
//! if t {
//! a[i]
//! } else {
//! ```
//!
//! There are a number of ways that the trans backend could choose to
-//! compile this (e.g. a `[bool, ..10]` array for each such moved array;
+//! compile this (e.g. a `[bool; 10]` array for each such moved array;
//! or an `Option<uint>` for each moved array). From the viewpoint of the
//! borrow-checker, the important thing is to record what kind of fragment
//! is implied by the relevant moves.
//! The first thing that the probe phase does is to create a series of
//! *steps*. This is done by progressively dereferencing the receiver type
//! until it cannot be deref'd anymore, as well as applying an optional
-//! "unsize" step. So if the receiver has type `Rc<Box<[T, ..3]>>`, this
+//! "unsize" step. So if the receiver has type `Rc<Box<[T; 3]>>`, this
//! might yield:
//!
-//! Rc<Box<[T, ..3]>>
-//! Box<[T, ..3]>
-//! [T, ..3]
+//! Rc<Box<[T; 3]>>
+//! Box<[T; 3]>
+//! [T; 3]
//! [T]
//!
//! ### Candidate assembly
//! method.
//!
//! So, let's continue our example. Imagine that we were calling a method
-//! `foo` with the receiver `Rc<Box<[T, ..3]>>` and there is a trait `Foo`
+//! `foo` with the receiver `Rc<Box<[T; 3]>>` and there is a trait `Foo`
//! that defines it with `&self` for the type `Rc<U>` as well as a method
//! on the type `Box` that defines `Foo` but with `&mut self`. Then we
//! might have two candidates:
//!
-//! &Rc<Box<[T, ..3]>> from the impl of `Foo` for `Rc<U>` where `U=Box<T, ..3]>
-//! &mut Box<[T, ..3]>> from the inherent impl on `Box<U>` where `U=[T, ..3]`
+//! &Rc<Box<[T; 3]>> from the impl of `Foo` for `Rc<U>` where `U=Box<T; 3]>
+//! &mut Box<[T; 3]>> from the inherent impl on `Box<U>` where `U=[T; 3]`
//!
//! ### Candidate search
//!
//! that makes any of the candidates match. We pick the first step where
//! we find a match.
//!
-//! In the case of our example, the first step is `Rc<Box<[T, ..3]>>`,
+//! In the case of our example, the first step is `Rc<Box<[T; 3]>>`,
//! which does not itself match any candidate. But when we autoref it, we
-//! get the type `&Rc<Box<[T, ..3]>>` which does match. We would then
+//! get the type `&Rc<Box<[T; 3]>>` which does match. We would then
//! recursively consider all where-clauses that appear on the impl: if
//! those match (or we cannot rule out that they do), then this is the
//! method we would pick. Otherwise, we would continue down the series of
/// In this case, the expected type for the `&[1, 2, 3]` expression is
/// `&[int]`. If however we were to say that `[1, 2, 3]` has the
/// expectation `ExpectHasType([int])`, that would be too strong --
- /// `[1, 2, 3]` does not have the type `[int]` but rather `[int, ..3]`.
+ /// `[1, 2, 3]` does not have the type `[int]` but rather `[int; 3]`.
/// It is only the `&[1, 2, 3]` expression as a whole that can be coerced
/// to the type `&[int]`. Therefore, we propagate this more limited hint,
/// which still is useful, because it informs integer literals and the like.
// are indexed by the `ParamKind` (type, lifetime, self). Note
// that there are no marker types for self, so the entries for
// self are always None.
- invariant_lang_items: [Option<ast::DefId>, ..2],
- covariant_lang_items: [Option<ast::DefId>, ..2],
- contravariant_lang_items: [Option<ast::DefId>, ..2],
+ invariant_lang_items: [Option<ast::DefId>; 2],
+ covariant_lang_items: [Option<ast::DefId>; 2],
+ contravariant_lang_items: [Option<ast::DefId>; 2],
unsafe_lang_item: Option<ast::DefId>,
// These are pointers to common `ConstantTerm` instances
fn add_constraints_from_crate<'a, 'tcx>(terms_cx: TermsContext<'a, 'tcx>,
krate: &ast::Crate)
-> ConstraintContext<'a, 'tcx> {
- let mut invariant_lang_items = [None, ..2];
- let mut covariant_lang_items = [None, ..2];
- let mut contravariant_lang_items = [None, ..2];
+ let mut invariant_lang_items = [None; 2];
+ let mut covariant_lang_items = [None; 2];
+ let mut contravariant_lang_items = [None; 2];
covariant_lang_items[TypeParam as uint] =
terms_cx.tcx.lang_items.covariant_type();
blockhtml: Option<extern "C" fn(*mut hoedown_buffer, *const hoedown_buffer,
*mut libc::c_void)>,
header: Option<headerfn>,
- other: [libc::size_t, ..28],
+ other: [libc::size_t; 28],
}
#[repr(C)]
#[test]
fn test_to_base64_crlf_line_break() {
- assert!(![0u8, ..1000].to_base64(Config {line_length: None, ..STANDARD})
+ assert!(![0u8; 1000].to_base64(Config {line_length: None, ..STANDARD})
.contains("\r\n"));
assert_eq!(b"foobar".to_base64(Config {line_length: Some(4),
..STANDARD}),
#[test]
fn test_to_base64_lf_line_break() {
- assert!(![0u8, ..1000].to_base64(Config {line_length: None,
+ assert!(![0u8; 1000].to_base64(Config {line_length: None,
newline: Newline::LF,
..STANDARD})
.as_slice()
fn spaces(wr: &mut io::Writer, mut n: uint) -> Result<(), io::IoError> {
const LEN: uint = 16;
- static BUF: [u8, ..LEN] = [b' ', ..LEN];
+ static BUF: [u8; LEN] = [b' '; LEN];
while n >= LEN {
try!(wr.write(&BUF));
}
}
-static ASCII_LOWERCASE_MAP: [u8, ..256] = [
+static ASCII_LOWERCASE_MAP: [u8; 256] = [
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
];
-static ASCII_UPPERCASE_MAP: [u8, ..256] = [
+static ASCII_UPPERCASE_MAP: [u8; 256] = [
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
/// let file = File::open(&Path::new("message.txt"));
/// let mut reader = BufferedReader::new(file);
///
-/// let mut buf = [0, ..100];
+/// let mut buf = [0; 100];
/// match reader.read(&mut buf) {
/// Ok(nread) => println!("Read {} bytes", nread),
/// Err(e) => println!("error reading: {}", e)
/// stream.write("hello, world".as_bytes());
/// stream.flush();
///
-/// let mut buf = [0, ..100];
+/// let mut buf = [0; 100];
/// match stream.read(&mut buf) {
/// Ok(nread) => println!("Read {} bytes", nread),
/// Err(e) => println!("error reading: {}", e)
/// # drop(tx);
/// let mut reader = ChanReader::new(rx);
///
-/// let mut buf = [0u8, ..100];
+/// let mut buf = [0u8; 100];
/// match reader.read(&mut buf) {
/// Ok(nread) => println!("Read {} bytes", nread),
/// Err(e) => println!("read error: {}", e),
}).detach();
let mut reader = ChanReader::new(rx);
- let mut buf = [0u8, ..3];
+ let mut buf = [0u8; 3];
assert_eq!(Ok(0), reader.read(&mut []));
assert!(size <= 8u);
match size {
1u => f(&[n as u8]),
- 2u => f(unsafe { & transmute::<_, [u8, ..2]>((n as u16).to_le()) }),
- 4u => f(unsafe { & transmute::<_, [u8, ..4]>((n as u32).to_le()) }),
- 8u => f(unsafe { & transmute::<_, [u8, ..8]>(n.to_le()) }),
+ 2u => f(unsafe { & transmute::<_, [u8; 2]>((n as u16).to_le()) }),
+ 4u => f(unsafe { & transmute::<_, [u8; 4]>((n as u32).to_le()) }),
+ 8u => f(unsafe { & transmute::<_, [u8; 8]>(n.to_le()) }),
_ => {
let mut bytes = vec!();
assert!(size <= 8u);
match size {
1u => f(&[n as u8]),
- 2u => f(unsafe { & transmute::<_, [u8, ..2]>((n as u16).to_be()) }),
- 4u => f(unsafe { & transmute::<_, [u8, ..4]>((n as u32).to_be()) }),
- 8u => f(unsafe { & transmute::<_, [u8, ..8]>(n.to_be()) }),
+ 2u => f(unsafe { & transmute::<_, [u8; 2]>((n as u16).to_be()) }),
+ 4u => f(unsafe { & transmute::<_, [u8; 4]>((n as u32).to_be()) }),
+ 8u => f(unsafe { & transmute::<_, [u8; 8]>(n.to_be()) }),
_ => {
let mut bytes = vec!();
let mut i = size;
panic!("index out of bounds");
}
- let mut buf = [0u8, ..8];
+ let mut buf = [0u8; 8];
unsafe {
let ptr = data.as_ptr().offset(start as int);
let out = buf.as_mut_ptr();
fn binary_file() {
use rand::{StdRng, Rng};
- let mut bytes = [0, ..1024];
+ let mut bytes = [0; 1024];
StdRng::new().ok().unwrap().fill_bytes(&mut bytes);
let tmpdir = tmpdir();
/// # #![allow(unused_must_use)]
/// use std::io::BufWriter;
///
-/// let mut buf = [0, ..4];
+/// let mut buf = [0; 4];
/// {
/// let mut w = BufWriter::new(&mut buf);
/// w.write(&[0, 1, 2]);
#[test]
fn test_buf_writer() {
- let mut buf = [0 as u8, ..9];
+ let mut buf = [0 as u8; 9];
{
let mut writer = BufWriter::new(&mut buf);
assert_eq!(writer.tell(), Ok(0));
#[test]
fn test_buf_writer_seek() {
- let mut buf = [0 as u8, ..8];
+ let mut buf = [0 as u8; 8];
{
let mut writer = BufWriter::new(&mut buf);
assert_eq!(writer.tell(), Ok(0));
#[test]
fn test_buf_writer_error() {
- let mut buf = [0 as u8, ..2];
+ let mut buf = [0 as u8; 2];
let mut writer = BufWriter::new(&mut buf);
writer.write(&[0]).unwrap();
assert_eq!(reader.tell(), Ok(1));
let b: &[_] = &[0];
assert_eq!(buf, b);
- let mut buf = [0, ..4];
+ let mut buf = [0; 4];
assert_eq!(reader.read(&mut buf), Ok(4));
assert_eq!(reader.tell(), Ok(5));
let b: &[_] = &[1, 2, 3, 4];
assert_eq!(reader.len(), 7);
let b: &[_] = &[0];
assert_eq!(buf.as_slice(), b);
- let mut buf = [0, ..4];
+ let mut buf = [0; 4];
assert_eq!(reader.read(&mut buf), Ok(4));
assert_eq!(reader.len(), 3);
let b: &[_] = &[1, 2, 3, 4];
assert_eq!(reader.tell(), Ok(1));
let b: &[_] = &[0];
assert_eq!(buf, b);
- let mut buf = [0, ..4];
+ let mut buf = [0; 4];
assert_eq!(reader.read(&mut buf), Ok(4));
assert_eq!(reader.tell(), Ok(5));
let b: &[_] = &[1, 2, 3, 4];
#[test]
fn io_read_at_least() {
let mut r = MemReader::new(vec![1, 2, 3, 4, 5, 6, 7, 8]);
- let mut buf = [0, ..3];
+ let mut buf = [0; 3];
assert!(r.read_at_least(buf.len(), &mut buf).is_ok());
let b: &[_] = &[1, 2, 3];
assert_eq!(buf, b);
#[bench]
fn bench_mem_reader(b: &mut Bencher) {
b.iter(|| {
- let buf = [5 as u8, ..100].to_vec();
+ let buf = [5 as u8; 100].to_vec();
{
let mut rdr = MemReader::new(buf);
for _i in range(0u, 10) {
#[bench]
fn bench_buf_writer(b: &mut Bencher) {
b.iter(|| {
- let mut buf = [0 as u8, ..100];
+ let mut buf = [0 as u8; 100];
{
let mut wr = BufWriter::new(&mut buf);
for _i in range(0u, 10) {
#[bench]
fn bench_buf_reader(b: &mut Bencher) {
b.iter(|| {
- let buf = [5 as u8, ..100];
+ let buf = [5 as u8; 100];
{
let mut rdr = BufReader::new(&buf);
for _i in range(0u, 10) {
/// Write a single char, encoded as UTF-8.
#[inline]
fn write_char(&mut self, c: char) -> IoResult<()> {
- let mut buf = [0u8, ..4];
+ let mut buf = [0u8; 4];
let n = c.encode_utf8(buf.as_mut_slice()).unwrap_or(0);
self.write(buf[..n])
}
fn test_read_at_least() {
let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()),
vec![GoodBehavior(uint::MAX)]);
- let buf = &mut [0u8, ..5];
+ let buf = &mut [0u8; 5];
assert!(r.read_at_least(1, buf).unwrap() >= 1);
assert!(r.read_exact(5).unwrap().len() == 5); // read_exact uses read_at_least
assert!(r.read_at_least(0, buf).is_ok());
}
fn read_ipv4_addr_impl(&mut self) -> Option<IpAddr> {
- let mut bs = [0u8, ..4];
+ let mut bs = [0u8; 4];
let mut i = 0;
while i < 4 {
if i != 0 && self.read_given_char('.').is_none() {
fn read_ipv6_addr_impl(&mut self) -> Option<IpAddr> {
fn ipv6_addr_from_head_tail(head: &[u16], tail: &[u16]) -> IpAddr {
assert!(head.len() + tail.len() <= 8);
- let mut gs = [0u16, ..8];
+ let mut gs = [0u16; 8];
gs.clone_from_slice(head);
gs.slice_mut(8 - tail.len(), 8).clone_from_slice(tail);
Ipv6Addr(gs[0], gs[1], gs[2], gs[3], gs[4], gs[5], gs[6], gs[7])
}
- fn read_groups(p: &mut Parser, groups: &mut [u16, ..8], limit: uint) -> (uint, bool) {
+ fn read_groups(p: &mut Parser, groups: &mut [u16; 8], limit: uint) -> (uint, bool) {
let mut i = 0;
while i < limit {
if i < limit - 1 {
(i, false)
}
- let mut head = [0u16, ..8];
+ let mut head = [0u16; 8];
let (head_size, head_ipv4) = read_groups(self, &mut head, 8);
if head_size == 8 {
return None;
}
- let mut tail = [0u16, ..8];
+ let mut tail = [0u16; 8];
let (tail_size, _) = read_groups(self, &mut tail, 8 - head_size);
Some(ipv6_addr_from_head_tail(head[..head_size], tail[..tail_size]))
}
rx.recv();
let mut c = TcpStream::connect(addr).unwrap();
- let mut b = [0, ..10];
+ let mut b = [0; 10];
assert_eq!(c.read(&mut b), Ok(1));
c.write(&[1]).unwrap();
rx.recv();
/// Err(e) => panic!("couldn't bind socket: {}", e),
/// };
///
-/// let mut buf = [0, ..10];
+/// let mut buf = [0; 10];
/// match socket.recv_from(&mut buf) {
/// Ok((amt, src)) => {
/// // Send a reply to the socket we received data from
rx.recv(); // don't close the pipe until the other read has finished
});
- let mut buf = [0, ..10];
+ let mut buf = [0; 10];
input.read(&mut buf).unwrap();
tx.send(());
}
use os::last_os_error;
// Fetch the kern.maxfilesperproc value
- let mut mib: [libc::c_int, ..2] = [CTL_KERN, KERN_MAXFILESPERPROC];
+ let mut mib: [libc::c_int; 2] = [CTL_KERN, KERN_MAXFILESPERPROC];
let mut maxfiles: libc::c_int = 0;
let mut size: libc::size_t = size_of_val(&maxfiles) as libc::size_t;
if sysctl(&mut mib[0], 2, &mut maxfiles as *mut libc::c_int as *mut libc::c_void, &mut size,
impl Buffer for ZeroReader {
fn fill_buf<'a>(&'a mut self) -> io::IoResult<&'a [u8]> {
- static DATA: [u8, ..64] = [0, ..64];
+ static DATA: [u8; 64] = [0; 64];
Ok(DATA.as_slice())
}
// This is just for integral types, the largest of which is a u64. The
// smallest base that we can have is 2, so the most number of digits we're
// ever going to have is 64
- let mut buf = [0u8, ..64];
+ let mut buf = [0u8; 64];
let mut cur = 0;
// Loop at least once to make sure at least a `0` gets emitted.
use io::{Writer, Seek};
// The radix can be as low as 2, so we need at least 64 characters for a
// base 2 number, and then we need another for a possible '-' character.
- let mut buf = [0u8, ..65];
+ let mut buf = [0u8; 65];
let amt = {
let mut wr = ::io::BufWriter::new(&mut buf);
(write!(&mut wr, "{}", ::fmt::radix(n, radix as u8))).unwrap();
}
fn getrandom_next_u32() -> u32 {
- let mut buf: [u8, ..4] = [0u8, ..4];
+ let mut buf: [u8; 4] = [0u8; 4];
getrandom_fill_bytes(&mut buf);
- unsafe { mem::transmute::<[u8, ..4], u32>(buf) }
+ unsafe { mem::transmute::<[u8; 4], u32>(buf) }
}
fn getrandom_next_u64() -> u64 {
- let mut buf: [u8, ..8] = [0u8, ..8];
+ let mut buf: [u8; 8] = [0u8; 8];
getrandom_fill_bytes(&mut buf);
- unsafe { mem::transmute::<[u8, ..8], u64>(buf) }
+ unsafe { mem::transmute::<[u8; 8], u64>(buf) }
}
#[cfg(all(target_os = "linux",
static GETRANDOM_AVAILABLE: AtomicBool = INIT_ATOMIC_BOOL;
if !GETRANDOM_CHECKED.load(Relaxed) {
- let mut buf: [u8, ..0] = [];
+ let mut buf: [u8; 0] = [];
let result = getrandom(&mut buf);
let available = if result == -1 {
let err = errno() as libc::c_int;
}
// Convert the arguments into a stack-allocated string
- let mut msg = [0u8, ..512];
+ let mut msg = [0u8; 512];
let mut w = BufWriter { buf: &mut msg, pos: 0 };
let _ = write!(&mut w, "{}", args);
let msg = str::from_utf8(w.buf[mut ..w.pos]).unwrap_or("aborted");
try!(writeln!(w, "stack backtrace:"));
// 100 lines should be enough
const SIZE: uint = 100;
- let mut buf: [*mut libc::c_void, ..SIZE] = unsafe {mem::zeroed()};
+ let mut buf: [*mut libc::c_void; SIZE] = unsafe {mem::zeroed()};
let cnt = unsafe { backtrace(buf.as_mut_ptr(), SIZE as libc::c_int) as uint};
// skipping the first one as it is write itself
// tested if this is required or not.
unsafe fn init_state() -> *mut backtrace_state {
static mut STATE: *mut backtrace_state = 0 as *mut backtrace_state;
- static mut LAST_FILENAME: [libc::c_char, ..256] = [0, ..256];
+ static mut LAST_FILENAME: [libc::c_char; 256] = [0; 256];
if !STATE.is_null() { return STATE }
let selfname = if cfg!(target_os = "freebsd") ||
cfg!(target_os = "dragonfly") {
#[repr(C)]
#[cfg(target_word_size = "32")]
pub struct sigset_t {
- __val: [libc::c_ulong, ..32],
+ __val: [libc::c_ulong; 32],
}
#[repr(C)]
#[cfg(target_word_size = "64")]
pub struct sigset_t {
- __val: [libc::c_ulong, ..16],
+ __val: [libc::c_ulong; 16],
}
}
pub sa_handler: extern fn(libc::c_int),
pub sa_mask: sigset_t,
sa_restorer: *mut libc::c_void,
- sa_resv: [libc::c_int, ..1],
+ sa_resv: [libc::c_int; 1],
}
unsafe impl ::kinds::Send for sigaction { }
#[repr(C)]
pub struct sigset_t {
- __val: [libc::c_ulong, ..32],
+ __val: [libc::c_ulong; 32],
}
}
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
#[repr(C)]
pub struct sigset_t {
- bits: [u32, ..4],
+ bits: [u32; 4],
}
// This structure has more fields, but we're not all that interested in
let mut writer = FileDesc::new(writer, true);
writer.write(b"test").ok().unwrap();
- let mut buf = [0u8, ..4];
+ let mut buf = [0u8; 4];
match reader.read(&mut buf) {
Ok(4) => {
assert_eq!(buf[0], 't' as u8);
}
pub unsafe fn pipe() -> IoResult<(FileDesc, FileDesc)> {
- let mut fds = [0, ..2];
+ let mut fds = [0; 2];
if libc::pipe(fds.as_mut_ptr()) == 0 {
Ok((FileDesc::new(fds[0], true), FileDesc::new(fds[1], true)))
} else {
let p = Process{ pid: pid };
drop(output);
- let mut bytes = [0, ..8];
+ let mut bytes = [0; 8];
return match input.read(&mut bytes) {
Ok(8) => {
assert!(combine(CLOEXEC_MSG_FOOTER) == combine(bytes.slice(4, 8)),
// handler we're going to start receiving signals.
fn register_sigchld() -> (libc::c_int, c::sigaction) {
unsafe {
- let mut pipes = [0, ..2];
+ let mut pipes = [0; 2];
assert_eq!(libc::pipe(pipes.as_mut_ptr()), 0);
set_nonblocking(pipes[0], true).ok().unwrap();
set_nonblocking(pipes[1], true).ok().unwrap();
fn drain(fd: libc::c_int) -> bool {
let mut ret = false;
loop {
- let mut buf = [0u8, ..1];
+ let mut buf = [0u8; 1];
match unsafe {
libc::read(fd, buf.as_mut_ptr() as *mut libc::c_void,
buf.len() as libc::size_t)
#[cfg(target_word_size = "32")]
#[repr(C)]
pub struct sigset_t {
- __val: [libc::c_ulong, ..32],
+ __val: [libc::c_ulong; 32],
}
#[cfg(target_word_size = "64")]
#[repr(C)]
pub struct sigset_t {
- __val: [libc::c_ulong, ..16],
+ __val: [libc::c_ulong; 16],
}
#[repr(C)]
writerThreadId: libc::c_int,
pendingReaders: libc::c_int,
pendingWriters: libc::c_int,
- reserved: [*mut libc::c_void, ..4],
+ reserved: [*mut libc::c_void; 4],
}
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
writerThreadId: 0,
pendingReaders: 0,
pendingWriters: 0,
- reserved: [0 as *mut _, ..4],
+ reserved: [0 as *mut _; 4],
};
}
struct SYMBOL_INFO {
SizeOfStruct: libc::c_ulong,
TypeIndex: libc::c_ulong,
- Reserved: [u64, ..2],
+ Reserved: [u64; 2],
Index: libc::c_ulong,
Size: libc::c_ulong,
ModBase: u64,
AddrStack: ADDRESS64,
AddrBStore: ADDRESS64,
FuncTableEntry: *mut libc::c_void,
- Params: [u64, ..4],
+ Params: [u64; 4],
Far: libc::BOOL,
Virtual: libc::BOOL,
- Reserved: [u64, ..3],
+ Reserved: [u64; 3],
KdHelp: KDHELP64,
}
KiUserExceptionDispatcher: u64,
StackBase: u64,
StackLimit: u64,
- Reserved: [u64, ..5],
+ Reserved: [u64; 5],
}
#[cfg(target_arch = "x86")]
ErrorSelector: libc::DWORD,
DataOffset: libc::DWORD,
DataSelector: libc::DWORD,
- RegisterArea: [u8, ..80],
+ RegisterArea: [u8; 80],
Cr0NpxState: libc::DWORD,
}
#[repr(C)]
pub struct CONTEXT {
- _align_hack: [simd::u64x2, ..0], // FIXME align on 16-byte
+ _align_hack: [simd::u64x2; 0], // FIXME align on 16-byte
P1Home: DWORDLONG,
P2Home: DWORDLONG,
P3Home: DWORDLONG,
#[repr(C)]
pub struct M128A {
- _align_hack: [simd::u64x2, ..0], // FIXME align on 16-byte
+ _align_hack: [simd::u64x2; 0], // FIXME align on 16-byte
Low: c_ulonglong,
High: c_longlong
}
#[repr(C)]
pub struct FLOATING_SAVE_AREA {
- _align_hack: [simd::u64x2, ..0], // FIXME align on 16-byte
- _Dummy: [u8, ..512] // FIXME: Fill this out
+ _align_hack: [simd::u64x2; 0], // FIXME align on 16-byte
+ _Dummy: [u8; 512] // FIXME: Fill this out
}
pub fn init_frame(frame: &mut super::STACKFRAME64,
// fully understand. Here we explicitly make the pipe non-inheritable,
// which means to pass it to a subprocess they need to be duplicated
// first, as in std::run.
- let mut fds = [0, ..2];
+ let mut fds = [0; 2];
match libc::pipe(fds.as_mut_ptr(), 1024 as ::libc::c_uint,
(libc::O_BINARY | libc::O_NOINHERIT) as c_int) {
0 => {
pub cfg: CrateConfig,
/// the previous token or None (only stashed sometimes).
pub last_token: Option<Box<token::Token>>,
- pub buffer: [TokenAndSpan, ..4],
+ pub buffer: [TokenAndSpan; 4],
pub buffer_start: int,
pub buffer_end: int,
pub tokens_consumed: uint,
(&None, &Some(ref e)) => (e.span.lo, e.span.hi),
(&None, &None) => (DUMMY_SP.lo, DUMMY_SP.hi),
};
- ExprIndex(expr, self.mk_expr(lo, hi, self.mk_range(start, end)))
+ ExprIndex(expr, self.mk_expr(lo, hi, ExprRange(start, end)))
}
pub fn mk_range(&mut self,
/// Container for static and dynamic variable arrays
pub struct Variables {
/// Static variables A-Z
- sta: [Param, ..26],
+ sta: [Param; 26],
/// Dynamic variables a-z
- dyn: [Param, ..26]
+ dyn: [Param; 26]
}
impl Variables {
#[allow(non_snake_case)]
#[repr(C)]
struct CONSOLE_SCREEN_BUFFER_INFO {
- dwSize: [libc::c_short, ..2],
- dwCursorPosition: [libc::c_short, ..2],
+ dwSize: [libc::c_short; 2],
+ dwCursorPosition: [libc::c_short; 2],
wAttributes: libc::WORD,
- srWindow: [libc::c_short, ..4],
- dwMaximumWindowSize: [libc::c_short, ..2],
+ srWindow: [libc::c_short; 4],
+ dwMaximumWindowSize: [libc::c_short; 2],
}
#[allow(non_snake_case)]
if n == 0 { n = 1; }
let mut total_run = Duration::nanoseconds(0);
- let samples : &mut [f64] = &mut [0.0_f64, ..50];
+ let samples : &mut [f64] = &mut [0.0_f64; 50];
loop {
let mut summ = None;
let mut summ5 = None;
}
// https://tools.ietf.org/html/rfc3629
-static UTF8_CHAR_WIDTH: [u8, ..256] = [
+static UTF8_CHAR_WIDTH: [u8; 256] = [
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x1F
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
return Some(tmp);
}
- let mut buf = [0u16, ..2];
+ let mut buf = [0u16; 2];
self.chars.next().map(|ch| {
let n = ch.encode_utf16(buf.as_mut_slice()).unwrap_or(0);
if n == 2 { self.extra = buf[1]; }
// #4264 fixed-length vector types
-pub fn foo(_: [int, ..3]) {}
+pub fn foo(_: [int; 3]) {}
pub fn bar() {
const FOO: uint = 5u - 4u;
- let _: [(), ..FOO] = [()];
+ let _: [(); FOO] = [()];
let _ : [(), ..1u] = [()];
// and tuples
assert_eq!(size_of::<(u8, Box<int>)>(), size_of::<Option<(u8, Box<int>)>>());
// and fixed-size arrays
- assert_eq!(size_of::<[Box<int>, ..1]>(), size_of::<Option<[Box<int>, ..1]>>());
+ assert_eq!(size_of::<[Box<int>; 1]>(), size_of::<Option<[Box<int>; 1]>>());
// Should apply to NonZero
assert_eq!(size_of::<NonZero<uint>>(), size_of::<Option<NonZero<uint>>>());
}
enum e3 {
- a([u16, ..0], u8), b
+ a([u16; 0], u8), b
}
pub fn main() {