I would like to know if in rust, there is a more standard way of doing what I am currently doing with my vector ?
For a little bit of context, I am creating a port scanner and I have a Config structure containing a vector with the ports to scan, that is passed to most of my functions, but most of them work with the current port to scan, not a vector.
What I am currently doing is storing the index of the current port in an other field of my struct like that :
pub struct Config {
// snip
pub target_ports: Vec<u16>,
pub current_port: u16,
}
But I feel that this is far from optimal, is there a type that would allow me to recreate this behavior in a more standard way ?
Could you help me find the most suited data type for this use case ?
Thanks