fn main() {
let f1 = Feature {};
let f2 = Feature {};
let mut holder = Holder { features : vec![ f1, f2] };
do_sth(&mut holder.features[0], &mut holder.features[1]);
}
struct Holder {
features : Vec<Feature>
}
struct Feature {
}
fn do_sth(feature1 : &mut Feature, feature2 : &mut Feature) {
}
I know why compiler can not work, and know how to solve it in this simple codes, but my question is, if I can only get ‘holder’ not ‘f1’ or ‘f2’, in other words, I can only get Feature from ‘holder’, how to satisfy the function do_sth, assume the function do_sth is in other mod, and know nothing about ‘holder’ or ‘f1’ or ‘f2’, only function do_sth know is ‘Feature’.