35 lines
737 B
Rust
35 lines
737 B
Rust
struct Point {
|
|
x: i32,
|
|
y: i32,
|
|
}
|
|
|
|
fn main() {
|
|
let mut stack = Vec::new();
|
|
|
|
stack.push(1);
|
|
stack.push(2);
|
|
stack.push(3);
|
|
|
|
while let Some(top) = stack.pop() {
|
|
println!("{}", top);
|
|
}
|
|
|
|
let p = Point { x: 0, y: 7 };
|
|
|
|
match p {
|
|
Point { x, y: 0 } => println!("On the x axis at {}", x),
|
|
Point { x: 0, y } => println!("On the y axis at {}", y),
|
|
Point { x, y } => println!("On neither axis: ({}, {})", x, y),
|
|
}
|
|
|
|
let ((feet, inches), Point { x, y }) = ((3, 10), Point { x: 3, y: -10 });
|
|
println!("{}, {}, {}, {}", feet, inches, x, y);
|
|
|
|
let x = 4;
|
|
let y = false;
|
|
|
|
match x {
|
|
4 | 5 | 6 if y => println!("yes"),
|
|
_ => println!("no"),
|
|
}
|
|
} |