Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 88d2ee7

Browse files
struct3.rs completed
1 parent ba2213b commit 88d2ee7

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed
491 KB
Binary file not shown.

‎5. Compound Data Types/5.5 Structs/structs3.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,18 @@ fn check_color(p: Color) {
1919
assert_eq!(__, 255);
2020
}
2121
*/
22+
struct Color(i32, i32, i32);
23+
struct Point(i32, i32, i32);
24+
fn main() {
25+
let v = Point(0, 127, 255);
26+
check_color(v);
27+
28+
println!("Success!");
29+
}
30+
31+
fn check_color(p: Point) {
32+
let Point(x, _, z) = p;
33+
assert_eq!(x, 0);
34+
assert_eq!(p.1, 127);
35+
assert_eq!(z, 255);
36+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /