1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 use std::string::String;
13 fn test_stack_assign() {
14 let s: String = "a".to_string();
15 println!("{}", s.clone());
16 let t: String = "a".to_string();
18 let u: String = "b".to_string();
22 fn test_heap_lit() { "a big string".to_string(); }
24 fn test_heap_assign() {
25 let s: String = "a big ol' string".to_string();
26 let t: String = "a big ol' string".to_string();
28 let u: String = "a bad ol' string".to_string();
33 let s = "a big ol' string".to_string();
38 let mut s = String::new();
40 assert_eq!(s.as_slice(), "a");
42 let mut s = String::from_str("a");
44 println!("{}", s.clone());
45 assert_eq!(s.as_slice(), "ab");
47 let mut s = String::from_str("c");
49 assert!(s.as_slice() == "coffee");
52 assert!(s.as_slice() == "coffee&tea");