rust/tests/run-pass/products.rs

33 lines
568 B
Rust
Raw Normal View History

2016-04-06 04:45:06 -05:00
fn tuple() -> (i16,) {
2016-03-12 21:32:24 -06:00
(1,)
}
2016-04-06 04:45:06 -05:00
fn tuple_2() -> (i16, i16) {
2016-03-12 21:32:24 -06:00
(1, 2)
}
2016-04-06 04:45:06 -05:00
fn tuple_5() -> (i16, i16, i16, i16, i16) {
2016-03-12 21:32:24 -06:00
(1, 2, 3, 4, 5)
}
2016-04-22 07:38:46 -05:00
#[derive(Debug, PartialEq)]
2016-03-13 07:48:04 -05:00
struct Pair { x: i8, y: i8 }
2016-03-12 21:32:24 -06:00
fn pair() -> Pair {
Pair { x: 10, y: 20 }
}
2016-03-13 07:48:04 -05:00
fn field_access() -> (i8, i8) {
let mut p = Pair { x: 10, y: 20 };
p.x += 5;
(p.x, p.y)
}
2016-04-22 03:34:14 -05:00
2016-04-22 07:38:46 -05:00
fn main() {
assert_eq!(tuple(), (1,));
assert_eq!(tuple_2(), (1, 2));
assert_eq!(tuple_5(), (1, 2, 3, 4, 5));
assert_eq!(pair(), Pair { x: 10, y: 20} );
assert_eq!(field_access(), (15, 20));
}