小编Afs*_*fsa的帖子

Rust 中 .. 和 _ 有什么区别?

在这种情况下,两个句点和下划线之间有什么区别:

 let a = Some("a");
    match a {
        Some(_) => println!("we are in match _"),

        _ => panic!(),
    }
    match a {
        Some(..) => println!("we are in match .."),
        _ => panic!(),
    }
Run Code Online (Sandbox Code Playgroud)

两者都可以编译并运行,但是为什么要选择其中一个而不是另一个呢?

pattern-matching match rust

27
推荐指数
1
解决办法
1993
查看次数

标签 统计

match ×1

pattern-matching ×1

rust ×1