I'm doing a poker assignment in which a base of 2 hands is given and my goal is to figure out in each hand what the highest card is. I've tried to pass in the reference to each array to another function that is supposed to figure it out:
fn highest_card(c: &[(i32, char)], d: &[(i32, char)]) {
let mut max = 0;
let mut m: usize = 0;
let n: usize = 0;
while m < c.len() {
if c[m].n > max {
max = c[m].n;
}
m += 1;
}
println!("The max number is: {}", max);
}
fn main() {
let hand1 = [(3, 'H'), (10, 'S'), (4, 'S'), (4, 'C'), (5, 'C')];
let hand2 = [(2, 'H'), (2, 'S'), (5, 'S'), (2, 'C'), (13, 'C')];
let xxx = highest_card(&hand1, &hand2);
}
When running this, it displays the error:
error[E0609]: no field `n` on type `(i32, char)`
--> src/main.rs:7:17
|
7 | if c[m].n > max {
| ^
error[E0609]: no field `n` on type `(i32, char)`
--> src/main.rs:8:24
|
8 | max = c[m].n;
| ^
What should I do to address this issue?