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);
}

这里记录的是所有权

posted @ 2024-04-15 11:18  ukyo--BlackJesus  阅读(3)  评论(0编辑  收藏  举报