官术网_书友最值得收藏!

Irrefutable patterns

Another form of pattern matching is irrefutable patterns. A pattern is irrefutable when there's only one way to match it and it always succeeds. For instance, another way to get the elements of a tuple is with an irrefutable pattern:

let tuple = (24, 42);
let (a, b) = tuple;
println!("{}, {}", a, b);

In the second line, we assign the first element of the tuple to a and the second to b.

主站蜘蛛池模板: 沾化县| 柯坪县| 葵青区| 杨浦区| 定襄县| 习水县| 木里| 本溪市| 西宁市| 咸丰县| 集贤县| 建德市| 佛教| 宁夏| 新沂市| 华阴市| 广南县| 德令哈市| 邓州市| 枝江市| 山东省| 镶黄旗| 东光县| 台东市| 凤山市| 富平县| 武义县| 屯门区| 翼城县| 九江县| 吴江市| 古丈县| 永兴县| 温州市| 景东| 米泉市| 晋中市| 哈巴河县| 镶黄旗| 怀宁县| 女性|