当前位置:网站首页>Rust: how to match a string?

Rust: how to match a string?

2022-04-23 18:03:00 Xu Yeping

Don't talk nonsense , Paste the code directly to see the example !

fn main() {
    
    let s = String::from("hello");
    match &s as &str {
    
        "hello" => println!("hello"),
        _ => (),
    }
}

版权声明
本文为[Xu Yeping]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230544498401.html