I just confirmed how the Vec::contains
works. I wrote code below and it looked working fine.
But I don't know why it works because it compares &String
types. Does it mean String comparison works even they aren't dereferenced?
struct NewStruct {
string_vec: Vec<Option<String>>,
}
fn main() {
let mut mys = NewStruct {
string_vec: Vec::<Option<String>>::new(),
};
mys.string_vec.push(Some("new array".to_string()));
let ref_st = mys.string_vec.iter().filter(|o|o.is_some()).map(|o|o.as_ref().unwrap()).collect::<Vec<&String>>();
println!("result:{:?}", ref_st.contains(&&("some string".to_string())));
println!("result:{:?}", ref_st.contains(&&("new array".to_string())));
println!("Hello, world!");
f64::from(1234_u64 as i32);
}