Rust 4.1

///
/// https://kaisery.github.io/trpl-zh-cn/ch04-01-what-is-ownership.html
fn main() {
    let mut s = String::from("hello");
    s.push_str(",world!");
    println!("{}",s);

    let s1= String::from("world");
    let s2 = s1.clone();

    println!("s1 = {}, s2 = {}",s1,s2);

    let x = 5;
    let y = x;
    println!("x = {}, y = {}",x,y);
}

這裏記錄的是所有權

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章