let a = [0i; 20]; // a: [int; 20]
```
-Arrays have type `[T,..N]`. We'll talk about this `T` notation later, when we
+Arrays have type `[T; N]`. We'll talk about this `T` notation later, when we
cover generics.
You can get the number of elements in an array `a` with `a.len()`, and use
fn get_mut(&mut self, index: uint) -> Option<&mut T>;
/// Work with `self` as a mut slice.
- /// Primarily intended for getting a &mut [T] from a [T, ..N].
+ /// Primarily intended for getting a &mut [T] from a [T; N].
#[stable]
fn as_mut_slice(&mut self) -> &mut [T];
}
// shouldn't panic
- let mut v: [uint, .. 0] = [];
+ let mut v: [uint; 0] = [];
v.sort();
let mut v = [0xDEADBEEFu];
fn test_sort_stability() {
for len in range(4i, 25) {
for _ in range(0u, 10) {
- let mut counts = [0i, .. 10];
+ let mut counts = [0i; 10];
// create a vector like [(6, 1), (5, 1), (6, 2), ...],
// where the first item of each tuple is random, but
use core::iter::order;
// official Unicode test data
// from http://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.txt
- let test_same: [(_, &[_]), .. 325] = [
+ let test_same: [(_, &[_]); 325] = [
("\u{20}\u{20}", &["\u{20}", "\u{20}"]),
("\u{20}\u{308}\u{20}", &["\u{20}\u{308}", "\u{20}"]),
("\u{20}\u{D}", &["\u{20}", "\u{D}"]),
("\u{646}\u{200D}\u{20}", &["\u{646}\u{200D}", "\u{20}"]),
];
- let test_diff: [(_, &[_], &[_]), .. 23] = [
+ let test_diff: [(_, &[_], &[_]); 23] = [
("\u{20}\u{903}", &["\u{20}\u{903}"], &["\u{20}", "\u{903}"]), ("\u{20}\u{308}\u{903}",
&["\u{20}\u{308}\u{903}"], &["\u{20}\u{308}", "\u{903}"]), ("\u{D}\u{308}\u{903}",
&["\u{D}", "\u{308}\u{903}"], &["\u{D}", "\u{308}", "\u{903}"]), ("\u{A}\u{308}\u{903}",
($($N:expr)+) => {
$(
#[stable]
- impl<T:Copy> Clone for [T, ..$N] {
- fn clone(&self) -> [T, ..$N] {
+ impl<T:Copy> Clone for [T; $N] {
+ fn clone(&self) -> [T; $N] {
*self
}
}
#[unstable = "waiting for Show to stabilize"]
- impl<T:fmt::Show> fmt::Show for [T, ..$N] {
+ impl<T:fmt::Show> fmt::Show for [T; $N] {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Show::fmt(&self[], f)
}
}
#[stable]
- impl<A, B> PartialEq<[B, ..$N]> for [A, ..$N] where A: PartialEq<B> {
+ impl<A, B> PartialEq<[B; $N]> for [A; $N] where A: PartialEq<B> {
#[inline]
- fn eq(&self, other: &[B, ..$N]) -> bool {
+ fn eq(&self, other: &[B; $N]) -> bool {
self[] == other[]
}
#[inline]
- fn ne(&self, other: &[B, ..$N]) -> bool {
+ fn ne(&self, other: &[B; $N]) -> bool {
self[] != other[]
}
}
#[stable]
- impl<'a, A, B, Rhs> PartialEq<Rhs> for [A, ..$N] where
+ impl<'a, A, B, Rhs> PartialEq<Rhs> for [A; $N] where
A: PartialEq<B>,
Rhs: Deref<[B]>,
{
}
#[stable]
- impl<'a, A, B, Lhs> PartialEq<[B, ..$N]> for Lhs where
+ impl<'a, A, B, Lhs> PartialEq<[B; $N]> for Lhs where
A: PartialEq<B>,
Lhs: Deref<[A]>
{
#[inline(always)]
- fn eq(&self, other: &[B, ..$N]) -> bool { PartialEq::eq(&**self, other[]) }
+ fn eq(&self, other: &[B; $N]) -> bool { PartialEq::eq(&**self, other[]) }
#[inline(always)]
- fn ne(&self, other: &[B, ..$N]) -> bool { PartialEq::ne(&**self, other[]) }
+ fn ne(&self, other: &[B; $N]) -> bool { PartialEq::ne(&**self, other[]) }
}
#[stable]
- impl<T:Eq> Eq for [T, ..$N] { }
+ impl<T:Eq> Eq for [T; $N] { }
#[stable]
- impl<T:PartialOrd> PartialOrd for [T, ..$N] {
+ impl<T:PartialOrd> PartialOrd for [T; $N] {
#[inline]
- fn partial_cmp(&self, other: &[T, ..$N]) -> Option<Ordering> {
+ fn partial_cmp(&self, other: &[T; $N]) -> Option<Ordering> {
PartialOrd::partial_cmp(&self[], &other[])
}
#[inline]
- fn lt(&self, other: &[T, ..$N]) -> bool {
+ fn lt(&self, other: &[T; $N]) -> bool {
PartialOrd::lt(&self[], &other[])
}
#[inline]
- fn le(&self, other: &[T, ..$N]) -> bool {
+ fn le(&self, other: &[T; $N]) -> bool {
PartialOrd::le(&self[], &other[])
}
#[inline]
- fn ge(&self, other: &[T, ..$N]) -> bool {
+ fn ge(&self, other: &[T; $N]) -> bool {
PartialOrd::ge(&self[], &other[])
}
#[inline]
- fn gt(&self, other: &[T, ..$N]) -> bool {
+ fn gt(&self, other: &[T; $N]) -> bool {
PartialOrd::gt(&self[], &other[])
}
}
#[stable]
- impl<T:Ord> Ord for [T, ..$N] {
+ impl<T:Ord> Ord for [T; $N] {
#[inline]
- fn cmp(&self, other: &[T, ..$N]) -> Ordering {
+ fn cmp(&self, other: &[T; $N]) -> Ordering {
Ord::cmp(&self[], &other[])
}
}
impl<S: Writer> Hash<S> for $ty {
#[inline]
fn hash(&self, state: &mut S) {
- let a: [u8, ..::$ty::BYTES] = unsafe {
+ let a: [u8; ::$ty::BYTES] = unsafe {
mem::transmute((*self as $uty).to_le() as $ty)
};
state.write(a.as_slice())
#[repr(C)]
#[deriving(Copy)] pub struct WSAPROTOCOLCHAIN {
pub ChainLen: c_int,
- pub ChainEntries: [DWORD, ..MAX_PROTOCOL_CHAIN as uint],
+ pub ChainEntries: [DWORD; MAX_PROTOCOL_CHAIN as uint],
}
pub type LPWSAPROTOCOLCHAIN = *mut WSAPROTOCOLCHAIN;
pub iSecurityScheme: c_int,
pub dwMessageSize: DWORD,
pub dwProviderReserved: DWORD,
- pub szProtocol: [u8, ..(WSAPROTOCOL_LEN as uint) + 1u],
+ pub szProtocol: [u8; (WSAPROTOCOL_LEN as uint) + 1u],
}
pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO;
#[deriving(Copy)]
pub struct ChaChaRng {
- buffer: [u32, ..STATE_WORDS], // Internal buffer of output
- state: [u32, ..STATE_WORDS], // Initial state
+ buffer: [u32; STATE_WORDS], // Internal buffer of output
+ state: [u32; STATE_WORDS], // Initial state
index: uint, // Index into state
}
static EMPTY: ChaChaRng = ChaChaRng {
- buffer: [0, ..STATE_WORDS],
- state: [0, ..STATE_WORDS],
+ buffer: [0; STATE_WORDS],
+ state: [0; STATE_WORDS],
index: STATE_WORDS
};
}
#[inline]
-fn core(output: &mut [u32, ..STATE_WORDS], input: &[u32, ..STATE_WORDS]) {
+fn core(output: &mut [u32; STATE_WORDS], input: &[u32; STATE_WORDS]) {
*output = *input;
for _ in range(0, CHACHA_ROUNDS / 2) {
/// fixed key of 8 zero words.
pub fn new_unseeded() -> ChaChaRng {
let mut rng = EMPTY;
- rng.init(&[0, ..KEY_WORDS]);
+ rng.init(&[0; KEY_WORDS]);
rng
}
/// ```
/// [1]: Daniel J. Bernstein. [*Extending the Salsa20
/// nonce.*](http://cr.yp.to/papers.html#xsalsa)
- fn init(&mut self, key: &[u32, ..KEY_WORDS]) {
+ fn init(&mut self, key: &[u32; KEY_WORDS]) {
self.state[0] = 0x61707865;
self.state[1] = 0x3320646E;
self.state[2] = 0x79622D32;
fn reseed(&mut self, seed: &'a [u32]) {
// reset state
- self.init(&[0u32, ..KEY_WORDS]);
+ self.init(&[0u32; KEY_WORDS]);
// set key in place
let key = self.state.slice_mut(4, 4+KEY_WORDS);
for (k, s) in key.iter_mut().zip(seed.iter()) {
impl Rand for ChaChaRng {
fn rand<R: Rng>(other: &mut R) -> ChaChaRng {
- let mut key : [u32, ..KEY_WORDS] = [0, ..KEY_WORDS];
+ let mut key : [u32; KEY_WORDS] = [0; KEY_WORDS];
for word in key.iter_mut() {
*word = other.gen();
}
// Tables for distributions which are sampled using the ziggurat
// algorithm. Autogenerated by `ziggurat_tables.py`.
-pub type ZigTable = &'static [f64, .. 257];
+pub type ZigTable = &'static [f64; 257];
pub static ZIG_NORM_R: f64 = 3.654152885361008796;
-pub static ZIG_NORM_X: [f64, .. 257] =
+pub static ZIG_NORM_X: [f64; 257] =
[3.910757959537090045, 3.654152885361008796, 3.449278298560964462, 3.320244733839166074,
3.224575052047029100, 3.147889289517149969, 3.083526132001233044, 3.027837791768635434,
2.978603279880844834, 2.934366867207854224, 2.894121053612348060, 2.857138730872132548,
0.487443966121754335, 0.463634336771763245, 0.437518402186662658, 0.408389134588000746,
0.375121332850465727, 0.335737519180459465, 0.286174591747260509, 0.215241895913273806,
0.000000000000000000];
-pub static ZIG_NORM_F: [f64, .. 257] =
+pub static ZIG_NORM_F: [f64; 257] =
[0.000477467764586655, 0.001260285930498598, 0.002609072746106363, 0.004037972593371872,
0.005522403299264754, 0.007050875471392110, 0.008616582769422917, 0.010214971439731100,
0.011842757857943104, 0.013497450601780807, 0.015177088307982072, 0.016880083152595839,
0.932060075968990209, 0.945198953453078028, 0.959879091812415930, 0.977101701282731328,
1.000000000000000000];
pub static ZIG_EXP_R: f64 = 7.697117470131050077;
-pub static ZIG_EXP_X: [f64, .. 257] =
+pub static ZIG_EXP_X: [f64; 257] =
[8.697117470131052741, 7.697117470131050077, 6.941033629377212577, 6.478378493832569696,
6.144164665772472667, 5.882144315795399869, 5.666410167454033697, 5.482890627526062488,
5.323090505754398016, 5.181487281301500047, 5.054288489981304089, 4.938777085901250530,
0.253658363385912022, 0.233790483059674731, 0.212671510630966620, 0.189958689622431842,
0.165127622564187282, 0.137304980940012589, 0.104838507565818778, 0.063852163815001570,
0.000000000000000000];
-pub static ZIG_EXP_F: [f64, .. 257] =
+pub static ZIG_EXP_F: [f64; 257] =
[0.000167066692307963, 0.000454134353841497, 0.000967269282327174, 0.001536299780301573,
0.002145967743718907, 0.002788798793574076, 0.003460264777836904, 0.004157295120833797,
0.004877655983542396, 0.005619642207205489, 0.006381905937319183, 0.007163353183634991,
#[deriving(Copy)]
pub struct IsaacRng {
cnt: u32,
- rsl: [u32, ..RAND_SIZE_UINT],
- mem: [u32, ..RAND_SIZE_UINT],
+ rsl: [u32; RAND_SIZE_UINT],
+ mem: [u32; RAND_SIZE_UINT],
a: u32,
b: u32,
c: u32
static EMPTY: IsaacRng = IsaacRng {
cnt: 0,
- rsl: [0, ..RAND_SIZE_UINT],
- mem: [0, ..RAND_SIZE_UINT],
+ rsl: [0; RAND_SIZE_UINT],
+ mem: [0; RAND_SIZE_UINT],
a: 0, b: 0, c: 0
};
#[deriving(Copy)]
pub struct Isaac64Rng {
cnt: uint,
- rsl: [u64, .. RAND_SIZE_64],
- mem: [u64, .. RAND_SIZE_64],
+ rsl: [u64; RAND_SIZE_64],
+ mem: [u64; RAND_SIZE_64],
a: u64,
b: u64,
c: u64,
static EMPTY_64: Isaac64Rng = Isaac64Rng {
cnt: 0,
- rsl: [0, .. RAND_SIZE_64],
- mem: [0, .. RAND_SIZE_64],
+ rsl: [0; RAND_SIZE_64],
+ mem: [0; RAND_SIZE_64],
a: 0, b: 0, c: 0,
};
let mut a = self.a;
let mut b = self.b + self.c;
const MIDPOINT: uint = RAND_SIZE_64 / 2;
- const MP_VEC: [(uint, uint), .. 2] = [(0,MIDPOINT), (MIDPOINT, 0)];
+ const MP_VEC: [(uint, uint); 2] = [(0,MIDPOINT), (MIDPOINT, 0)];
macro_rules! ind (
($x:expr) => {
*self.mem.get_unchecked(($x as uint >> 3) & (RAND_SIZE_64 - 1))
/// ```rust
/// use std::rand::{thread_rng, Rng};
///
- /// let mut v = [0u8, .. 13579];
+ /// let mut v = [0u8; 13579];
/// thread_rng().fill_bytes(&mut v);
/// println!("{}", v.as_slice());
/// ```
}
}
-impl SeedableRng<[u32, .. 4]> for XorShiftRng {
+impl SeedableRng<[u32; 4]> for XorShiftRng {
/// Reseed an XorShiftRng. This will panic if `seed` is entirely 0.
- fn reseed(&mut self, seed: [u32, .. 4]) {
+ fn reseed(&mut self, seed: [u32; 4]) {
assert!(!seed.iter().all(|&x| x == 0),
"XorShiftRng.reseed called with an all zero seed.");
}
/// Create a new XorShiftRng. This will panic if `seed` is entirely 0.
- fn from_seed(seed: [u32, .. 4]) -> XorShiftRng {
+ fn from_seed(seed: [u32; 4]) -> XorShiftRng {
assert!(!seed.iter().all(|&x| x == 0),
"XorShiftRng::from_seed called with an all zero seed.");
chars: CharReader::new(input),
}.run(start, end);
- type Captures = [Option<uint>, ..$num_cap_locs];
+ type Captures = [Option<uint>; $num_cap_locs];
struct Nfa<'t> {
which: MatchKind,
struct Threads {
which: MatchKind,
- queue: [Thread, ..$num_insts],
- sparse: [uint, ..$num_insts],
+ queue: [Thread; $num_insts],
+ sparse: [uint; $num_insts],
size: uint,
}
// Small vector optimization. This should catch 100% of the cases that
// we care about.
if ixs.len() < 16 {
- let mut small_vec = [ C_i32(self.ccx, 0), ..16 ];
+ let mut small_vec = [ C_i32(self.ccx, 0); 16 ];
for (small_vec_e, &ix) in small_vec.iter_mut().zip(ixs.iter()) {
*small_vec_e = C_i32(self.ccx, ix as i32);
}
pub enum CleanupScopeKind<'blk, 'tcx: 'blk> {
CustomScopeKind,
AstScopeKind(ast::NodeId),
- LoopScopeKind(ast::NodeId, [Block<'blk, 'tcx>, ..EXIT_MAX])
+ LoopScopeKind(ast::NodeId, [Block<'blk, 'tcx>; EXIT_MAX])
}
impl<'blk, 'tcx: 'blk> fmt::Show for CleanupScopeKind<'blk, 'tcx> {
fn push_loop_cleanup_scope(&self,
id: ast::NodeId,
- exits: [Block<'blk, 'tcx>, ..EXIT_MAX]) {
+ exits: [Block<'blk, 'tcx>; EXIT_MAX]) {
debug!("push_loop_cleanup_scope({})",
self.ccx.tcx().map.node_to_string(id));
assert_eq!(Some(id), self.top_ast_scope());
fn push_ast_cleanup_scope(&self, id: NodeInfo);
fn push_loop_cleanup_scope(&self,
id: ast::NodeId,
- exits: [Block<'blk, 'tcx>, ..EXIT_MAX]);
+ exits: [Block<'blk, 'tcx>; EXIT_MAX]);
fn push_custom_cleanup_scope(&self) -> CustomScopeIndex;
fn push_custom_cleanup_scope_with_debug_loc(&self,
debug_loc: NodeInfo)
}
fn escape_char(writer: &mut io::Writer, v: char) -> Result<(), io::IoError> {
- let mut buf = [0, .. 4];
+ let mut buf = [0; 4];
let len = v.encode_utf8(&mut buf).unwrap();
escape_bytes(writer, buf[mut ..len])
}
F: FnOnce(*const libc::c_char) -> T,
{
let c_str = if v.len() < BUF_LEN {
- let mut buf: [u8, .. BUF_LEN] = mem::uninitialized();
+ let mut buf: [u8; BUF_LEN] = mem::uninitialized();
slice::bytes::copy_memory(&mut buf, v);
buf[v.len()] = 0;
}
{
let mut read_stream = File::open_mode(filename, Open, Read);
- let mut read_buf = [0, .. 1028];
+ let mut read_buf = [0; 1028];
let read_str = match check!(read_stream.read(&mut read_buf)) {
-1|0 => panic!("shouldn't happen"),
n => str::from_utf8(read_buf[..n]).unwrap().to_string()
#[test]
fn file_test_io_non_positional_read() {
let message: &str = "ten-four";
- let mut read_mem = [0, .. 8];
+ let mut read_mem = [0; 8];
let tmpdir = tmpdir();
let filename = &tmpdir.join("file_rt_io_file_test_positional.txt");
{
#[test]
fn file_test_io_seek_and_tell_smoke_test() {
let message = "ten-four";
- let mut read_mem = [0, .. 4];
+ let mut read_mem = [0; 4];
let set_cursor = 4 as u64;
let mut tell_pos_pre_read;
let mut tell_pos_post_read;
let overwrite_msg = "-the-bar!!";
let final_msg = "foo-the-bar!!";
let seek_idx = 3i;
- let mut read_mem = [0, .. 13];
+ let mut read_mem = [0; 13];
let tmpdir = tmpdir();
let filename = &tmpdir.join("file_rt_io_file_test_seek_and_write.txt");
{
let chunk_one: &str = "qwer";
let chunk_two: &str = "asdf";
let chunk_three: &str = "zxcv";
- let mut read_mem = [0, .. 4];
+ let mut read_mem = [0; 4];
let tmpdir = tmpdir();
let filename = &tmpdir.join("file_rt_io_file_test_seek_shakedown.txt");
{
check!(w.write(msg));
}
let files = check!(readdir(dir));
- let mut mem = [0u8, .. 4];
+ let mut mem = [0u8; 4];
for f in files.iter() {
{
let n = f.filestem_str();
check!(File::create(&dir2.join("14")));
let mut files = check!(walk_dir(dir));
- let mut cur = [0u8, .. 2];
+ let mut cur = [0u8; 2];
for f in files {
let stem = f.filestem_str().unwrap();
let root = stem.as_bytes()[0] - b'0';
{
let mut rdr = MemReader::new(buf);
for _i in range(0u, 10) {
- let mut buf = [0 as u8, .. 10];
+ let mut buf = [0 as u8; 10];
rdr.read(&mut buf).unwrap();
- assert_eq!(buf.as_slice(), [5, .. 10].as_slice());
+ assert_eq!(buf.as_slice(), [5; 10].as_slice());
}
}
});
{
let mut wr = BufWriter::new(&mut buf);
for _i in range(0u, 10) {
- wr.write(&[5, .. 10]).unwrap();
+ wr.write(&[5; 10]).unwrap();
}
}
- assert_eq!(buf.as_slice(), [5, .. 100].as_slice());
+ assert_eq!(buf.as_slice(), [5; 100].as_slice());
});
}
{
let mut rdr = BufReader::new(&buf);
for _i in range(0u, 10) {
- let mut buf = [0 as u8, .. 10];
+ let mut buf = [0 as u8; 10];
rdr.read(&mut buf).unwrap();
- assert_eq!(buf, [5, .. 10]);
+ assert_eq!(buf, [5; 10]);
}
}
});
s.set_timeout(Some(20));
for i in range(0u, 1001) {
- match s.write(&[0, .. 128 * 1024]) {
+ match s.write(&[0; 128 * 1024]) {
Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {},
Err(IoError { kind: TimedOut, .. }) => break,
Err(e) => panic!("{}", e),
rx.recv();
let mut amt = 0;
while amt < 100 * 128 * 1024 {
- match s.read(&mut [0, ..128 * 1024]) {
+ match s.read(&mut [0;128 * 1024]) {
Ok(n) => { amt += n; }
Err(e) => panic!("{}", e),
}
tx.send(());
for _ in range(0u, 100) {
- assert!(s.write(&[0, ..128 * 1024]).is_ok());
+ assert!(s.write(&[0;128 * 1024]).is_ok());
}
}
let mut s = a.accept().unwrap();
s.set_write_timeout(Some(20));
for i in range(0u, 1001) {
- match s.write(&[0, .. 128 * 1024]) {
+ match s.write(&[0; 128 * 1024]) {
Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {},
Err(IoError { kind: TimedOut, .. }) => break,
Err(e) => panic!("{}", e),
s.set_timeout(Some(20));
for i in range(0i, 1001) {
- match s.write(&[0, .. 128 * 1024]) {
+ match s.write(&[0; 128 * 1024]) {
Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {},
Err(IoError { kind: TimedOut, .. }) => break,
Err(e) => panic!("{}", e),
rx.recv();
let mut amt = 0;
while amt < 100 * 128 * 1024 {
- match s.read(&mut [0, ..128 * 1024]) {
+ match s.read(&mut [0;128 * 1024]) {
Ok(n) => { amt += n; }
Err(e) => panic!("{}", e),
}
tx.send(());
for _ in range(0i, 100) {
- assert!(s.write(&[0, ..128 * 1024]).is_ok());
+ assert!(s.write(&[0;128 * 1024]).is_ok());
}
}
let mut s = a.accept().unwrap();
s.set_write_timeout(Some(20));
for i in range(0i, 1001) {
- match s.write(&[0, .. 128 * 1024]) {
+ match s.write(&[0; 128 * 1024]) {
Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {},
Err(IoError { kind: TimedOut, .. }) => break,
Err(e) => panic!("{}", e),
a.set_write_timeout(Some(1000));
for _ in range(0u, 100) {
- match a.send_to(&[0, ..4*1024], addr2) {
+ match a.send_to(&[0;4*1024], addr2) {
Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {},
Err(IoError { kind: TimedOut, .. }) => break,
Err(e) => panic!("other error: {}", e),
/// Copies all data from a `Reader` to a `Writer`.
pub fn copy<R: Reader, W: Writer>(r: &mut R, w: &mut W) -> io::IoResult<()> {
- let mut buf = [0, ..super::DEFAULT_BUF_SIZE];
+ let mut buf = [0; super::DEFAULT_BUF_SIZE];
loop {
let len = match r.read(&mut buf) {
Ok(len) => len,
#[bench]
fn rand_shuffle_100(b: &mut Bencher) {
let mut rng = weak_rng();
- let x : &mut[uint] = &mut [1,..100];
+ let x : &mut[uint] = &mut [1; 100];
b.iter(|| {
rng.shuffle(x);
})
impl Rng for OsRng {
fn next_u32(&mut self) -> u32 {
- let mut v = [0u8, .. 4];
+ let mut v = [0u8; 4];
self.fill_bytes(&mut v);
unsafe { mem::transmute(v) }
}
fn next_u64(&mut self) -> u64 {
- let mut v = [0u8, .. 8];
+ let mut v = [0u8; 8];
self.fill_bytes(&mut v);
unsafe { mem::transmute(v) }
}
impl Rng for OsRng {
fn next_u32(&mut self) -> u32 {
- let mut v = [0u8, .. 4];
+ let mut v = [0u8; 4];
self.fill_bytes(&mut v);
unsafe { mem::transmute(v) }
}
fn next_u64(&mut self) -> u64 {
- let mut v = [0u8, .. 8];
+ let mut v = [0u8; 8];
self.fill_bytes(&mut v);
unsafe { mem::transmute(v) }
}
r.next_u32();
r.next_u64();
- let mut v = [0u8, .. 1000];
+ let mut v = [0u8; 1000];
r.fill_bytes(&mut v);
}
// as possible (XXX: is this a good test?)
let mut r = OsRng::new().unwrap();
Thread::yield_now();
- let mut v = [0u8, .. 1000];
+ let mut v = [0u8; 1000];
for _ in range(0u, 100) {
r.next_u32();
#[test]
fn test_reader_rng_fill_bytes() {
let v = [1u8, 2, 3, 4, 5, 6, 7, 8];
- let mut w = [0u8, .. 8];
+ let mut w = [0u8; 8];
let mut rng = ReaderRng::new(MemReader::new(v.as_slice().to_vec()));
rng.fill_bytes(&mut w);
#[should_fail]
fn test_reader_rng_insufficient_bytes() {
let mut rng = ReaderRng::new(MemReader::new(vec!()));
- let mut v = [0u8, .. 3];
+ let mut v = [0u8; 3];
rng.fill_bytes(&mut v);
}
}
pub struct _Unwind_Exception {
pub exception_class: _Unwind_Exception_Class,
pub exception_cleanup: _Unwind_Exception_Cleanup_Fn,
- pub private: [_Unwind_Word, ..unwinder_private_data_size],
+ pub private: [_Unwind_Word; unwinder_private_data_size],
}
pub enum _Unwind_Context {}
//
// For more information, see below.
const MAX_CALLBACKS: uint = 16;
-static CALLBACKS: [atomic::AtomicUint, ..MAX_CALLBACKS] =
+static CALLBACKS: [atomic::AtomicUint; MAX_CALLBACKS] =
[atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,
atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,
atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,
uwe: uw::_Unwind_Exception {
exception_class: rust_exception_class(),
exception_cleanup: exception_cleanup,
- private: [0, ..uw::unwinder_private_data_size],
+ private: [0; uw::unwinder_private_data_size],
},
cause: Some(cause),
};
let mut storage: libc::sockaddr_storage = unsafe { mem::zeroed() };
let len = addr_to_sockaddr(addr, &mut storage);
- let mut hostbuf = [0 as c_char, ..NI_MAXHOST];
+ let mut hostbuf = [0 as c_char; NI_MAXHOST];
let res = unsafe {
getnameinfo(&storage as *const _ as *const libc::sockaddr, len,
#[repr(C)]
pub struct fd_set {
- fds_bits: [i32, ..(FD_SETSIZE / 32)]
+ fds_bits: [i32; (FD_SETSIZE / 32)]
}
pub fn fd_set(set: &mut fd_set, fd: i32) {
#[repr(C)]
pub struct fd_set {
// FIXME: shouldn't this be a c_ulong?
- fds_bits: [libc::uintptr_t, ..(FD_SETSIZE / uint::BITS)]
+ fds_bits: [libc::uintptr_t; (FD_SETSIZE / uint::BITS)]
}
pub fn fd_set(set: &mut fd_set, fd: i32) {
}
}
- let mut buf = [0 as c_char, ..TMPBUF_SZ];
+ let mut buf = [0 as c_char; TMPBUF_SZ];
let p = buf.as_mut_ptr();
unsafe {
pub fn getcwd() -> IoResult<Path> {
use c_str::CString;
- let mut buf = [0 as c_char, ..BUF_BYTES];
+ let mut buf = [0 as c_char; BUF_BYTES];
unsafe {
if libc::getcwd(buf.as_mut_ptr(), buf.len() as libc::size_t).is_null() {
Err(IoError::last_error())
#[repr(C)]
pub struct pthread_mutex_t {
__sig: libc::c_long,
- __opaque: [u8, ..__PTHREAD_MUTEX_SIZE__],
+ __opaque: [u8; __PTHREAD_MUTEX_SIZE__],
}
#[repr(C)]
pub struct pthread_cond_t {
__sig: libc::c_long,
- __opaque: [u8, ..__PTHREAD_COND_SIZE__],
+ __opaque: [u8; __PTHREAD_COND_SIZE__],
}
#[repr(C)]
pub struct pthread_rwlock_t {
__sig: libc::c_long,
- __opaque: [u8, ..__PTHREAD_RWLOCK_SIZE__],
+ __opaque: [u8; __PTHREAD_RWLOCK_SIZE__],
}
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
__sig: _PTHREAD_MUTEX_SIG_INIT,
- __opaque: [0, ..__PTHREAD_MUTEX_SIZE__],
+ __opaque: [0; __PTHREAD_MUTEX_SIZE__],
};
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
__sig: _PTHREAD_COND_SIG_INIT,
- __opaque: [0, ..__PTHREAD_COND_SIZE__],
+ __opaque: [0; __PTHREAD_COND_SIZE__],
};
pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
__sig: _PTHREAD_RWLOCK_SIG_INIT,
- __opaque: [0, ..__PTHREAD_RWLOCK_SIZE__],
+ __opaque: [0; __PTHREAD_RWLOCK_SIZE__],
};
}
#[repr(C)]
pub struct pthread_mutex_t {
__align: libc::c_longlong,
- size: [u8, ..__SIZEOF_PTHREAD_MUTEX_T],
+ size: [u8; __SIZEOF_PTHREAD_MUTEX_T],
}
#[repr(C)]
pub struct pthread_cond_t {
__align: libc::c_longlong,
- size: [u8, ..__SIZEOF_PTHREAD_COND_T],
+ size: [u8; __SIZEOF_PTHREAD_COND_T],
}
#[repr(C)]
pub struct pthread_rwlock_t {
__align: libc::c_longlong,
- size: [u8, ..__SIZEOF_PTHREAD_RWLOCK_T],
+ size: [u8; __SIZEOF_PTHREAD_RWLOCK_T],
}
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
__align: 0,
- size: [0, ..__SIZEOF_PTHREAD_MUTEX_T],
+ size: [0; __SIZEOF_PTHREAD_MUTEX_T],
};
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
__align: 0,
- size: [0, ..__SIZEOF_PTHREAD_COND_T],
+ size: [0; __SIZEOF_PTHREAD_COND_T],
};
pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
__align: 0,
- size: [0, ..__SIZEOF_PTHREAD_RWLOCK_T],
+ size: [0; __SIZEOF_PTHREAD_RWLOCK_T],
};
}
#[cfg(target_os = "android")]
// note that windows has this as 1, but it basically just means that
// the name is inline at the end of the struct. For us, we just bump
// the struct size up to MAX_SYM_NAME.
- Name: [libc::c_char, ..MAX_SYM_NAME],
+ Name: [libc::c_char; MAX_SYM_NAME],
}
EFlags: libc::DWORD,
Esp: libc::DWORD,
SegSs: libc::DWORD,
- ExtendedRegisters: [u8, ..MAXIMUM_SUPPORTED_EXTENSION],
+ ExtendedRegisters: [u8; MAXIMUM_SUPPORTED_EXTENSION],
}
#[repr(C)]
FltSave: FLOATING_SAVE_AREA,
- VectorRegister: [M128A, .. 26],
+ VectorRegister: [M128A; 26],
VectorControl: DWORDLONG,
DebugControl: DWORDLONG,
pub struct WSADATA {
pub wVersion: libc::WORD,
pub wHighVersion: libc::WORD,
- pub szDescription: [u8, ..WSADESCRIPTION_LEN + 1],
- pub szSystemStatus: [u8, ..WSASYS_STATUS_LEN + 1],
+ pub szDescription: [u8; WSADESCRIPTION_LEN + 1],
+ pub szSystemStatus: [u8; WSASYS_STATUS_LEN + 1],
pub iMaxSockets: u16,
pub iMaxUdpDg: u16,
pub lpVendorInfo: *mut u8,
pub iMaxSockets: u16,
pub iMaxUdpDg: u16,
pub lpVendorInfo: *mut u8,
- pub szDescription: [u8, ..WSADESCRIPTION_LEN + 1],
- pub szSystemStatus: [u8, ..WSASYS_STATUS_LEN + 1],
+ pub szDescription: [u8; WSADESCRIPTION_LEN + 1],
+ pub szSystemStatus: [u8; WSASYS_STATUS_LEN + 1],
}
pub type LPWSADATA = *mut WSADATA;
#[repr(C)]
pub struct WSANETWORKEVENTS {
pub lNetworkEvents: libc::c_long,
- pub iErrorCode: [libc::c_int, ..FD_MAX_EVENTS],
+ pub iErrorCode: [libc::c_int; FD_MAX_EVENTS],
}
pub type LPWSANETWORKEVENTS = *mut WSANETWORKEVENTS;
#[repr(C)]
pub struct fd_set {
fd_count: libc::c_uint,
- fd_array: [libc::SOCKET, ..FD_SETSIZE],
+ fd_array: [libc::SOCKET; FD_SETSIZE],
}
pub fn fd_set(set: &mut fd_set, s: libc::SOCKET) {
// MAKELANGID(LANG_SYSTEM_DEFAULT, SUBLANG_SYS_DEFAULT)
let langId = 0x0800 as DWORD;
- let mut buf = [0 as WCHAR, ..TMPBUF_SZ];
+ let mut buf = [0 as WCHAR; TMPBUF_SZ];
unsafe {
let res = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM |
use libc::GetCurrentDirectoryW;
use io::OtherIoError;
- let mut buf = [0 as u16, ..BUF_BYTES];
+ let mut buf = [0 as u16; BUF_BYTES];
unsafe {
if libc::GetCurrentDirectoryW(buf.len() as DWORD, buf.as_mut_ptr()) == 0 as DWORD {
return Err(IoError::last_error());
pub ExceptionRecord: *mut EXCEPTION_RECORD,
pub ExceptionAddress: LPVOID,
pub NumberParameters: DWORD,
- pub ExceptionInformation: [LPVOID, ..EXCEPTION_MAXIMUM_PARAMETERS]
+ pub ExceptionInformation: [LPVOID; EXCEPTION_MAXIMUM_PARAMETERS]
}
pub struct EXCEPTION_POINTERS {
});
MacItems::new(vec![quote_item!(ecx,
- pub static $name: [(&'static str, &'static str), ..$count] = $expr;
+ pub static $name: [(&'static str, &'static str); $count] = $expr;
).unwrap()].into_iter())
}
// Test that the old fixed length array syntax is a parsing error.
fn main() {
- let _x: [int, ..3] = [0i, 1, 2]; //~ ERROR
+ let _x: [int, ..3] = [0i, 1, 2]; //~ ERROR
}
// except according to those terms.
fn main() {
- let x: [int 3]; //~ ERROR expected one of `(`, `+`, `,`, `::`, `;`, or `]`, found `3`
+ let x: [int 3]; //~ ERROR expected one of `(`, `+`, `::`, `;`, or `]`, found `3`
}
#[cfg(target_word_size = "64")]
fn main() {
let n = 0u;
- let a = box [&n,..0xF000000000000000u];
+ let a = box [&n; 0xF000000000000000u];
println!("{}", a[0xFFFFFFu]);
}
#[cfg(target_word_size = "32")]
fn main() {
let n = 0u;
- let a = box [&n,..0xFFFFFFFFu];
+ let a = box [&n; 0xFFFFFFFFu];
println!("{}", a[0xFFFFFFu]);
}
// Trying to create a fixed-length vector with a negative size
fn main() {
- let _x = [0,..-1]; //~ ERROR found negative integer
+ let _x = [0; -1]; //~ ERROR found negative integer
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-type v = [int * 3]; //~ ERROR expected one of `(`, `+`, `,`, `::`, `;`, or `]`, found `*`
+type v = [int * 3]; //~ ERROR expected one of `(`, `+`, `::`, `;`, or `]`, found `*`
type v = [mut int];
//~^ ERROR expected identifier, found keyword `mut`
- //~^^ ERROR expected one of `(`, `+`, `,`, `::`, `;`, or `]`, found `int`
+ //~^^ ERROR expected one of `(`, `+`, `::`, `;`, or `]`, found `int`
const FOO: uint = 5u - 4u;
let _: [(); FOO] = [()];
- let _ : [(), ..1u] = [()];
+ let _ : [(); 1u] = [()];
- let _ = &([1i,2,3]) as *const _ as *const [int, ..3u];
+ let _ = &([1i,2,3]) as *const _ as *const [int; 3u];
format!("test");
}
-pub type Foo = [int, ..3u];
+pub type Foo = [int; 3u];
pub struct Bar {
- pub x: [int, ..3u]
+ pub x: [int; 3u]
}
-pub struct TupleBar([int, ..4u]);
+pub struct TupleBar([int; 4u]);
pub enum Baz {
- BazVariant([int, ..5u])
+ BazVariant([int; 5u])
}
pub fn id<T>(x: T) -> T { x }
pub fn use_id() {
- let _ = id::<[int, ..3u]>([1,2,3]);
+ let _ = id::<[int; 3u]>([1,2,3]);
}
// except according to those terms.
pub fn main() {
- let x = [1i,..100];
+ let x = [1i; 100];
let mut y = 0i;
for i in x.iter() {
if y > 10 {
// except according to those terms.
pub fn main() {
- let x = [1i,..100];
+ let x = [1i; 100];
let mut y = 0i;
for (n,i) in x.iter().enumerate() {
if n < 10 {
// except according to those terms.
pub fn main() {
- let x = [1i,..100];
- let y = [2i,..100];
+ let x = [1i; 100];
+ let y = [2i; 100];
let mut p = 0i;
let mut q = 0i;
for i in x.iter() {
// except according to those terms.
pub fn main() {
- let x = [1i,..100];
+ let x = [1i; 100];
let mut y = 0i;
for i in x.iter() {
y += *i
pub fn main() {
unsafe {
- ::std::mem::transmute::<[int,..1],int>([1])
+ ::std::mem::transmute::<[int; 1],int>([1])
};
}