I'm writing a function to read vectors from stdin, and here is what I have so far:
fn read_vector() -> (i64, i64, i64) {
let mut vec = (0, 0, 0);
let mut value = String::new();
for i in 0..3 {
io::stdin().read_line(&mut value).expect("Failed to read line");
vec.i = value.trim().parse().expect("Failed to read number!"); // error!
}
}
However, the annotated line contains an error:
error: no field `i` on type `({integer}, {integer}, {integer})`
--> src/main.rs:13:13
|
13 | vec.i = value.trim().parse().expect("Failed to read number!");
| ^
Reading the documentation entry doesn't reveal any get
, or similar function.
So, is there any way to get the i
th value of a tuple?