-// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
#[stable]
pub struct Box<T>(Unique<T>);
+ #[unstable]
+ impl<T> Box<T> {
+ /// Moves `x` into a freshly allocated box on the global exchange heap.
+ #[unstable]
+ pub fn new(x: T) -> Box<T> {
+ box x
+ }
+ }
+
#[stable]
impl<T: Default> Default for Box<T> {
#[stable]
fn cmp(&self, other: &Box<T>) -> Ordering {
Ord::cmp(&**self, &**other)
}
-
-#[stable]}
+}
+#[stable]
impl<T: ?Sized + Eq> Eq for Box<T> {}
+#[cfg(stage0)]
impl<S: hash::Writer, T: ?Sized + Hash<S>> Hash<S> for Box<T> {
#[inline]
fn hash(&self, state: &mut S) {
(**self).hash(state);
}
}
+#[cfg(not(stage0))]
+impl<S: hash::Hasher, T: ?Sized + Hash<S>> Hash<S> for Box<T> {
+ #[inline]
+ fn hash(&self, state: &mut S) {
+ (**self).hash(state);
+ }
+}
/// Extension methods for an owning `Any` trait object.
#[unstable = "post-DST and coherence changes, this will not be a trait but \
}
}
+#[stable]
impl<T: ?Sized + fmt::String> fmt::String for Box<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(&**self, f)
mod test {
#[test]
fn test_owned_clone() {
- let a = box 5i;
+ let a = Box::new(5i);
let b: Box<int> = a.clone();
assert!(a == b);
}
#[test]
fn any_move() {
- let a = box 8u as Box<Any>;
- let b = box Test as Box<Any>;
+ let a = Box::new(8u) as Box<Any>;
+ let b = Box::new(Test) as Box<Any>;
match a.downcast::<uint>() {
- Ok(a) => { assert!(a == box 8u); }
+ Ok(a) => { assert!(a == Box::new(8u)); }
Err(..) => panic!()
}
match b.downcast::<Test>() {
- Ok(a) => { assert!(a == box Test); }
+ Ok(a) => { assert!(a == Box::new(Test)); }
Err(..) => panic!()
}
- let a = box 8u as Box<Any>;
- let b = box Test as Box<Any>;
+ let a = Box::new(8u) as Box<Any>;
+ let b = Box::new(Test) as Box<Any>;
assert!(a.downcast::<Box<Test>>().is_err());
assert!(b.downcast::<Box<uint>>().is_err());
#[test]
fn test_show() {
- let a = box 8u as Box<Any>;
- let b = box Test as Box<Any>;
+ let a = Box::new(8u) as Box<Any>;
+ let b = Box::new(Test) as Box<Any>;
let a_str = a.to_str();
let b_str = b.to_str();
assert_eq!(a_str, "Box<Any>");
#[test]
fn deref() {
fn homura<T: Deref<Target=i32>>(_: T) { }
- homura(box 765i32);
+ homura(Box::new(765i32));
}
}
#![crate_name = "alloc"]
#![experimental]
+#![staged_api]
#![crate_type = "rlib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
#![no_std]
#![allow(unknown_features)]
#![feature(lang_items, unsafe_destructor)]
+ #![feature(box_syntax)]
#[macro_use]
extern crate core;
+
+#[cfg(all(not(feature = "external_funcs"), not(feature = "external_crate")))]
extern crate libc;
// Allow testing this library
#![crate_name = "collections"]
#![experimental]
+#![staged_api]
#![crate_type = "rlib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
#![allow(unknown_features)]
#![feature(unsafe_destructor, slicing_syntax)]
-#![feature(old_impl_check)]
+ #![feature(box_syntax)]
#![feature(unboxed_closures)]
+#![feature(old_impl_check)]
#![no_std]
#[macro_use]
pub use core::option; // necessary for panic!()
pub use core::clone; // deriving(Clone)
pub use core::cmp; // deriving(Eq, Ord, etc.)
- #[cfg(stage0)]
- pub use core::marker as kinds;
pub use core::marker; // deriving(Copy)
pub use core::hash; // deriving(Hash)
}
#![crate_name = "log"]
#![experimental = "use the crates.io `log` library instead"]
+#![staged_api]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")]
+
+ #![allow(unknown_features)]
#![feature(slicing_syntax)]
+ #![feature(box_syntax)]
#![deny(missing_docs)]
extern crate regex;
// Test the literal string from args against the current filter, if there
// is one.
match unsafe { FILTER.as_ref() } {
- Some(filter) if !filter.is_match(args.to_string().index(&FullRange)) => return,
+ Some(filter) if !filter.is_match(&args.to_string()[]) => return,
_ => {}
}
// Search for the longest match, the vector is assumed to be pre-sorted.
for directive in iter.rev() {
match directive.name {
- Some(ref name) if !module.starts_with(name.index(&FullRange)) => {},
+ Some(ref name) if !module.starts_with(&name[]) => {},
Some(..) | None => {
return level <= directive.level
}
/// `Once` primitive (and this function is called from that primitive).
fn init() {
let (mut directives, filter) = match os::getenv("RUST_LOG") {
- Some(spec) => directive::parse_logging_spec(spec.index(&FullRange)),
+ Some(spec) => directive::parse_logging_spec(&spec[]),
None => (Vec::new(), None),
};
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![experimental = "use the crates.io `regex` library instead"]
+#![staged_api]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/",
#![allow(unknown_features)]
#![feature(slicing_syntax)]
+ #![feature(box_syntax)]
#![deny(missing_docs)]
#[cfg(test)]
#![crate_name = "rustc"]
#![experimental]
+#![staged_api]
#![crate_type = "dylib"]
#![crate_type = "rlib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
#![allow(unknown_features)]
#![feature(quote)]
#![feature(slicing_syntax, unsafe_destructor)]
+ #![feature(box_syntax)]
#![feature(rustc_diagnostic_macros)]
#![feature(old_impl_check)]
#![crate_name = "rustc_driver"]
#![experimental]
+#![staged_api]
#![crate_type = "dylib"]
#![crate_type = "rlib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")]
+ #![allow(unknown_features)]
#![feature(quote)]
#![feature(slicing_syntax, unsafe_destructor)]
+ #![feature(box_syntax)]
#![feature(rustc_diagnostic_macros)]
extern crate arena;
use rustc_trans::back::link;
use rustc::session::{config, Session, build_session};
-use rustc::session::config::{Input, PrintRequest};
+use rustc::session::config::{Input, PrintRequest, UnstableFeatures};
use rustc::lint::Lint;
use rustc::lint;
use rustc::metadata;
let descriptions = diagnostics::registry::Registry::new(&DIAGNOSTICS);
match matches.opt_str("explain") {
Some(ref code) => {
- match descriptions.find_description(code.index(&FullRange)) {
+ match descriptions.find_description(&code[]) {
Some(ref description) => {
println!("{}", description);
}
None => {
- early_error(format!("no extended information for {}", code).index(&FullRange));
+ early_error(&format!("no extended information for {}", code)[]);
}
}
return;
early_error("no input filename given");
}
1u => {
- let ifile = matches.free[0].index(&FullRange);
+ let ifile = &matches.free[0][];
if ifile == "-" {
let contents = io::stdin().read_to_end().unwrap();
let src = String::from_utf8(contents).unwrap();
_ => early_error("multiple input filenames provided")
};
+ let mut sopts = sopts;
+ sopts.unstable_features = get_unstable_features_setting();
+
let mut sess = build_session(sopts, input_file_path, descriptions);
+
let cfg = config::build_configuration(&sess);
if print_crate_info(&sess, Some(&input), &odir, &ofile) {
return
driver::compile_input(sess, cfg, &input, &odir, &ofile, None);
}
+pub fn get_unstable_features_setting() -> UnstableFeatures {
+ // Whether this is a feature-staged build, i.e. on the beta or stable channel
+ let disable_unstable_features = option_env!("CFG_DISABLE_UNSTABLE_FEATURES").is_some();
+ // The secret key needed to get through the rustc build itself by
+ // subverting the unstable features lints
+ let bootstrap_secret_key = option_env!("CFG_BOOTSTRAP_KEY");
+ // The matching key to the above, only known by the build system
+ let bootstrap_provided_key = os::getenv("RUSTC_BOOTSTRAP_KEY");
+ match (disable_unstable_features, bootstrap_secret_key, bootstrap_provided_key) {
+ (_, Some(ref s), Some(ref p)) if s == p => UnstableFeatures::Cheat,
+ (true, _, _) => UnstableFeatures::Disallow,
+ (false, _, _) => UnstableFeatures::Default
+ }
+}
+
/// Returns a version string such as "0.12.0-dev".
pub fn release_str() -> Option<&'static str> {
option_env!("CFG_RELEASE")
for lint in lints.into_iter() {
let name = lint.name_lower().replace("_", "-");
println!(" {} {:7.7} {}",
- padded(name.index(&FullRange)), lint.default_level.as_str(), lint.desc);
+ padded(&name[]), lint.default_level.as_str(), lint.desc);
}
println!("\n");
};
let desc = to.into_iter().map(|x| x.as_str().replace("_", "-"))
.collect::<Vec<String>>().connect(", ");
println!(" {} {}",
- padded(name.index(&FullRange)), desc);
+ padded(&name[]), desc);
}
println!("\n");
};
}
let matches =
- match getopts::getopts(args.index(&FullRange), config::optgroups().index(&FullRange)) {
+ match getopts::getopts(&args[], &config::optgroups()[]) {
Ok(m) => m,
Err(f_stable_attempt) => {
// redo option parsing, including unstable options this time,
"run with `RUST_BACKTRACE=1` for a backtrace".to_string(),
];
for note in xs.iter() {
- emitter.emit(None, note.index(&FullRange), None, diagnostic::Note)
+ emitter.emit(None, ¬e[], None, diagnostic::Note)
}
match r.read_to_string() {
Ok(s) => println!("{}", s),
Err(e) => {
emitter.emit(None,
- format!("failed to read internal \
- stderr: {}", e).index(&FullRange),
+ &format!("failed to read internal \
+ stderr: {}", e)[],
None,
diagnostic::Error)
}
#![crate_name = "rustc_llvm"]
#![experimental]
+#![staged_api]
#![crate_type = "dylib"]
#![crate_type = "rlib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")]
+ #![allow(unknown_features)]
#![feature(link_args)]
+ #![feature(box_syntax)]
extern crate libc;
#![crate_name = "rustc_trans"]
#![experimental]
+#![staged_api]
#![crate_type = "dylib"]
#![crate_type = "rlib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")]
+ #![allow(unknown_features)]
#![feature(quote)]
#![feature(slicing_syntax, unsafe_destructor)]
+ #![feature(box_syntax)]
#![feature(rustc_diagnostic_macros)]
extern crate arena;
#![crate_name = "rustc_typeck"]
#![experimental]
+#![staged_api]
#![crate_type = "dylib"]
#![crate_type = "rlib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")]
+ #![allow(unknown_features)]
#![feature(quote)]
#![feature(slicing_syntax, unsafe_destructor)]
+ #![feature(box_syntax)]
#![feature(rustc_diagnostic_macros)]
#![allow(non_camel_case_types)]
Ok(_) => true,
Err(ref terr) => {
tcx.sess.span_err(span,
- format!("{}: {}",
+ &format!("{}: {}",
msg(),
ty::type_err_to_str(tcx,
- terr)).index(&FullRange));
+ terr))[]);
ty::note_and_explain_type_err(tcx, terr);
false
}
}
_ => {
tcx.sess.span_bug(main_span,
- format!("main has a non-function type: found \
+ &format!("main has a non-function type: found \
`{}`",
ppaux::ty_to_string(tcx,
- main_t)).index(&FullRange));
+ main_t))[]);
}
}
}
}
_ => {
tcx.sess.span_bug(start_span,
- format!("start has a non-function type: found \
+ &format!("start has a non-function type: found \
`{}`",
- ppaux::ty_to_string(tcx, start_t)).index(&FullRange));
+ ppaux::ty_to_string(tcx, start_t))[]);
}
}
}
#![crate_name = "rustdoc"]
#![experimental]
+#![staged_api]
#![crate_type = "dylib"]
#![crate_type = "rlib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")]
#![feature(slicing_syntax)]
+ #![feature(box_syntax)]
extern crate arena;
extern crate getopts;
#![crate_name = "serialize"]
#![unstable = "deprecated in favor of rustc-serialize on crates.io"]
+#![staged_api]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")]
#![allow(unknown_features)]
-#![feature(slicing_syntax)]
+#![cfg_attr(stage0, allow(unused_attributes))]
+ #![feature(box_syntax)]
#![feature(old_impl_check)]
-#![cfg_attr(stage0, allow(unused_attributes))]
+#![feature(slicing_syntax)]
// test harness access
#[cfg(test)] extern crate test;
#![crate_name = "std"]
#![stable]
+#![staged_api]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
#![feature(linkage, thread_local, asm)]
#![feature(lang_items, unsafe_destructor)]
#![feature(slicing_syntax, unboxed_closures)]
+ #![feature(box_syntax)]
#![feature(old_impl_check)]
-#![cfg_attr(stage0, allow(unused_attributes))]
// Don't link to std. We are std.
#![no_std]
extern crate log;
#[macro_use]
-#[macro_reexport(assert, assert_eq, debug_assert, debug_assert_eq,
- unreachable, unimplemented, write, writeln)]
+#[macro_reexport(write, writeln)]
extern crate core;
#[macro_use]
#[cfg(not(test))] pub use core::cmp;
pub use core::default;
pub use core::finally;
+pub use core::hash;
pub use core::intrinsics;
pub use core::iter;
-#[cfg(stage0)] #[cfg(not(test))] pub use core::marker as kinds;
#[cfg(not(test))] pub use core::marker;
pub use core::mem;
#[cfg(not(test))] pub use core::ops;
/* Exported macros */
#[macro_use]
-pub mod macros;
+mod macros;
#[macro_use]
pub mod bitflags;
mod uint_macros;
#[path = "num/int.rs"] pub mod int;
+#[path = "num/isize.rs"] pub mod isize;
#[path = "num/i8.rs"] pub mod i8;
#[path = "num/i16.rs"] pub mod i16;
#[path = "num/i32.rs"] pub mod i32;
#[path = "num/i64.rs"] pub mod i64;
#[path = "num/uint.rs"] pub mod uint;
+#[path = "num/usize.rs"] pub mod usize;
#[path = "num/u8.rs"] pub mod u8;
#[path = "num/u16.rs"] pub mod u16;
#[path = "num/u32.rs"] pub mod u32;
/* Common data structures */
pub mod collections;
-pub mod hash;
/* Threads and communication */
pub use clone;
pub use cmp;
pub use hash;
+ pub use default;
pub use sync; // used for select!()
pub use error; // used for try!()
pub use vec; // used for vec![]
pub use cell; // used for tls!
pub use thread_local; // used for thread_local!
- #[cfg(stage0)]
- pub use marker as kinds;
pub use marker; // used for tls!
pub use ops; // used for bitflags!
("tuple_indexing", Accepted),
("associated_types", Accepted),
("visible_private_types", Active),
- ("slicing_syntax", Accepted),
+ ("slicing_syntax", Active),
+ ("box_syntax", Active),
("if_let", Accepted),
("while_let", Accepted),
fn gate_feature(&self, feature: &str, span: Span, explain: &str) {
if !self.has_feature(feature) {
self.span_handler.span_err(span, explain);
- self.span_handler.span_help(span, format!("add #![feature({})] to the \
+ self.span_handler.span_help(span, &format!("add #![feature({})] to the \
crate attributes to enable",
- feature).index(&FullRange));
+ feature)[]);
}
}
}
match i.node {
ast::ItemForeignMod(ref foreign_module) => {
- if attr::contains_name(i.attrs.index(&FullRange), "link_args") {
+ if attr::contains_name(&i.attrs[], "link_args") {
self.gate_feature("link_args", i.span,
"the `link_args` attribute is not portable \
across platforms, it is recommended to \
}
ast::ItemFn(..) => {
- if attr::contains_name(i.attrs.index(&FullRange), "plugin_registrar") {
+ if attr::contains_name(&i.attrs[], "plugin_registrar") {
self.gate_feature("plugin_registrar", i.span,
"compiler plugins are experimental and possibly buggy");
}
}
ast::ItemStruct(..) => {
- if attr::contains_name(i.attrs.index(&FullRange), "simd") {
+ if attr::contains_name(&i.attrs[], "simd") {
self.gate_feature("simd", i.span,
"SIMD types are experimental and possibly buggy");
}
removed in the future");
}
- if attr::contains_name(i.attrs.index(&FullRange),
+ if attr::contains_name(&i.attrs[],
"old_orphan_check") {
self.gate_feature(
"old_orphan_check",
"the new orphan check rules will eventually be strictly enforced");
}
- if attr::contains_name(i.attrs.index(&FullRange),
+ if attr::contains_name(&i.attrs[],
"old_impl_check") {
self.gate_feature("old_impl_check",
i.span,
}
fn visit_foreign_item(&mut self, i: &ast::ForeignItem) {
- if attr::contains_name(i.attrs.index(&FullRange), "linkage") {
+ if attr::contains_name(&i.attrs[], "linkage") {
self.gate_feature("linkage", i.span,
"the `linkage` attribute is experimental \
and not portable across platforms")
}
fn visit_expr(&mut self, e: &ast::Expr) {
- ast::ExprRange(..) => {
- self.gate_feature("slicing_syntax",
- e.span,
- "range syntax is experimental");
- }
+ match e.node {
+ ast::ExprBox(..) | ast::ExprUnary(ast::UnOp::UnUniq, _) => {
+ self.gate_feature("box_syntax",
+ e.span,
+ "box expression syntax is experimental in alpha release; \
+ you can call `Box::new` instead.");
+ }
+ _ => {}
+ }
visit::walk_expr(self, e);
}
but at the end of a slice (e.g. \
`[0, ..xs, 0]` are experimental")
}
+ ast::PatBox(..) => {
+ self.gate_feature("box_syntax",
+ pattern.span,
+ "box pattern syntax is experimental in alpha release");
+ }
_ => {}
}
visit::walk_pat(self, pattern)
#![crate_name = "syntax"]
#![experimental]
+#![staged_api]
#![crate_type = "dylib"]
#![crate_type = "rlib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
#![allow(unknown_features)]
#![feature(slicing_syntax)]
+ #![feature(box_syntax)]
#![feature(quote, unsafe_destructor)]
extern crate arena;
pub mod asm;
pub mod base;
pub mod build;
- pub mod bytes;
pub mod cfg;
pub mod cfg_attr;
pub mod concat;
pub mod deriving;
pub mod env;
pub mod expand;
- pub mod fmt;
pub mod format;
pub mod log_syntax;
pub mod mtwt;
#![crate_name = "term"]
#![experimental = "use the crates.io `term` library instead"]
+#![staged_api]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
#![allow(unknown_features)]
#![feature(slicing_syntax)]
+ #![feature(box_syntax)]
#![deny(missing_docs)]
#[macro_use] extern crate log;
#![crate_name = "test"]
#![experimental]
+#![staged_api]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")]
+ #![allow(unknown_features)]
#![feature(asm, slicing_syntax)]
+ #![feature(box_syntax)]
extern crate getopts;
extern crate regex;
st.write_failures().unwrap();
let s = match st.out {
- Raw(ref m) => String::from_utf8_lossy(m.index(&FullRange)),
+ Raw(ref m) => String::from_utf8_lossy(&m[]),
Pretty(_) => unreachable!()
};
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+ #![allow(unknown_features)]
+ #![feature(box_syntax)]
+
use std::thread::Thread;
use std::sync::mpsc::{channel, Sender};
impl Drop for Foo {
fn drop(&mut self) {
match self {
- &Foo::SimpleVariant(ref mut sender) => {
+ &mut Foo::SimpleVariant(ref mut sender) => {
sender.send(Message::DestructorRan).unwrap();
}
- &Foo::NestedVariant(_, _, ref mut sender) => {
+ &mut Foo::NestedVariant(_, _, ref mut sender) => {
sender.send(Message::DestructorRan).unwrap();
}
- &Foo::FailingVariant { .. } => {
+ &mut Foo::FailingVariant { .. } => {
panic!("Failed");
}
}
assert_eq!(receiver.recv().ok(), None);
let (sender, receiver) = channel();
- let _t = Thread::spawn(move|| {
+ let _t = Thread::scoped(move|| {
let v = Foo::FailingVariant { on_drop: SendOnDrop { sender: sender } };
});
assert_eq!(receiver.recv().unwrap(), Message::Dropped);
let (sender, receiver) = channel();
let _t = {
- Thread::spawn(move|| {
+ Thread::scoped(move|| {
let mut v = Foo::NestedVariant(box 42u, SendOnDrop {
sender: sender.clone()
}, sender.clone());
#![deny(warnings)]
#![allow(unused_must_use)]
+ #![allow(unknown_features)]
+ #![feature(box_syntax)]
use std::fmt;
// can do with them just yet (to test the output)
fn test_print() {
print!("hi");
- print!("{}", vec!(0u8));
+ print!("{:?}", vec!(0u8));
println!("hello");
println!("this is a {}", "test");
println!("{foo}", foo="bar");
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+ #![allow(unknown_features)]
+ #![feature(box_syntax)]
#![feature(unboxed_closures)]
use std::ops::{Deref, DerefMut};
impl DerefMut for X {
fn deref_mut(&mut self) -> &mut int {
- let &X(box ref mut x) = self;
+ let &mut X(box ref mut x) = self;
x
}
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+ #![allow(unknown_features)]
+ #![feature(box_syntax)]
+
use std::sync::mpsc::{channel, Sender};
use std::thread::Thread;
let (tx, rx) = channel();
let n = 100u;
let mut expected = 0u;
- for i in range(0u, n) {
+ let _t = range(0u, n).map(|i| {
+ expected += i;
let tx = tx.clone();
- Thread::spawn(move|| {
+ Thread::scoped(move|| {
child(&tx, i)
- });
- expected += i;
- }
+ })
+ }).collect::<Vec<_>>();
let mut actual = 0u;
for _ in range(0u, n) {