// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#[feature(managed_boxes)];
-
-fn wants_box(x: @str) { }
fn wants_uniq(x: ~str) { }
fn wants_slice(x: &str) { }
-fn has_box(x: @str) {
- wants_box(x);
- wants_uniq(x); //~ ERROR str storage differs: expected `~` but found `@`
- wants_slice(x);
-}
-
fn has_uniq(x: ~str) {
- wants_box(x); //~ ERROR str storage differs: expected `@` but found `~`
wants_uniq(x);
wants_slice(x);
}
fn has_slice(x: &str) {
- wants_box(x); //~ ERROR str storage differs: expected `@` but found `&`
wants_uniq(x); //~ ERROR str storage differs: expected `~` but found `&`
wants_slice(x);
}
@[1]; //~ ERROR type uses managed
//~^ ERROR type uses managed
fn f(_: @Clone) {} //~ ERROR type uses managed
- @""; //~ ERROR type uses managed
//~^ ERROR type uses managed
~2; //~ ERROR type uses owned
(&[1]).test_imm();
("test").test_imm();
(~"test").test_imm();
- (@"test").test_imm();
(&"test").test_imm();
// FIXME: Other types of mutable vecs don't currently exist
#[feature(managed_boxes)];
pub fn main() {
- let (&x, &y, &z) = (&3, &'a', &@"No pets!");
+ let (&x, &y) = (&3, &'a');
assert_eq!(x, 3);
assert_eq!(y, 'a');
- assert_eq!(z, @"No pets!");
}
pub fn main() {
assert_eq!(foo(&3), 3);
assert_eq!(foo(&'a'), 'a');
- assert_eq!(foo(&@"Dogs rule, cats drool"), @"Dogs rule, cats drool");
}
+++ /dev/null
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#[feature(managed_boxes)];
-
-pub fn main() {
- let _x : @str = @"hello";
-}
t!(format!("{}", 1.0f64), "1");
t!(format!("{}", "a"), "a");
t!(format!("{}", ~"a"), "a");
- t!(format!("{}", @"a"), "a");
t!(format!("{}", false), "false");
t!(format!("{}", 'a'), "a");
t!(format!("{:X}", 10u), "A");
t!(format!("{:s}", "foo"), "foo");
t!(format!("{:s}", ~"foo"), "foo");
- t!(format!("{:s}", @"foo"), "foo");
t!(format!("{:p}", 0x1234 as *int), "0x1234");
t!(format!("{:p}", 0x1234 as *mut int), "0x1234");
t!(format!("{:d}", A), "aloha");
{
assert!(compare("foo", "foo"));
assert!(compare(~"foo", ~"foo"));
- assert!(compare(@"foo", @"foo"));
}
+++ /dev/null
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#[feature(managed_boxes)];
-
-use std::hashmap::HashMap;
-
-pub fn main() {
- let mut x = HashMap::new();
- x.insert((@"abc", 0), 0);
-}
}
pub fn main() {
- assert_eq!(f1(@"a"), ~"found a");
assert_eq!(f1(~"b"), ~"found b");
assert_eq!(f1(&"c"), ~"not found");
assert_eq!(f1("d"), ~"not found");
- assert_eq!(f2(@"a"), ~"found a");
assert_eq!(f2(~"b"), ~"found b");
assert_eq!(f2(&"c"), ~"not found (c)");
assert_eq!(f2("d"), ~"not found (d)");
- assert_eq!(g1(@"a", @"b"), ~"found a,b");
assert_eq!(g1(~"b", ~"c"), ~"found b,c");
assert_eq!(g1(&"c", &"d"), ~"not found");
assert_eq!(g1("d", "e"), ~"not found");
- assert_eq!(g2(@"a", @"b"), ~"found a,b");
assert_eq!(g2(~"b", ~"c"), ~"found b,c");
assert_eq!(g2(&"c", &"d"), ~"not found (c, d)");
assert_eq!(g2("d", "e"), ~"not found (d, e)");
check_type!(~18: ~int);
check_type!(@19: @int);
check_type!(~"foo": ~str);
- check_type!(@"bar": @str);
check_type!(~[20, 22]: ~[int]);
check_type!(@[]: @[int]);
check_type!(@[24, 26]: @[int]);
check_type!(~int);
check_type!(@int);
check_type!(~str);
- check_type!(@str);
check_type!(~[int]);
check_type!(@[int]);
check_type!(extern fn());
}
fn visit_estr_box(&mut self) -> bool {
- self.align_to::<@str>();
- if ! self.inner().visit_estr_box() { return false; }
- self.bump_past::<@str>();
true
}
assert_eq!(map.find_equiv(&(~"cde")), Some(&c));
assert_eq!(map.find_equiv(&(~"def")), Some(&d));
- assert_eq!(map.find_equiv(&(@"abc")), Some(&a));
- assert_eq!(map.find_equiv(&(@"bcd")), Some(&b));
- assert_eq!(map.find_equiv(&(@"cde")), Some(&c));
- assert_eq!(map.find_equiv(&(@"def")), Some(&d));
-
assert_eq!(map.find_equiv(&SendStrStatic("abc")), Some(&a));
assert_eq!(map.find_equiv(&SendStrStatic("bcd")), Some(&b));
assert_eq!(map.find_equiv(&SendStrStatic("cde")), Some(&c));