我想从用户那里获取矢量形式的输入并使用循环打印它,然后通过迭代反转矢量
--modern
use std::io;
use std::str::FromStr;
fn main() {
let i = read_values::<f64>().unwrap();
for a in i.iter().rev() {
print!("{} ", a);
}
}
fn read_values<T: FromStr>() -> Result<Vec<T>, T::Err> {
let mut s = String::new();
io::stdin()
.read_line(&mut s)
.expect("could not read from stdin");
s.trim()
.split_whitespace()
.map(|word| word.parse())
.collect()
}
它只需要1个输入,但是我想输入多个,然后反转