pub fn do_find(a_sequence:&str,a_str: &str)->String
{
match a_sequence.split_whitespace().find(
|&word|{word == a_str}//Here, passing &word makes sense to me but passing just word doesn't make sense as find takes its operand by ref, yet I'm allowed to pass just word and it still compiles
)
{
Some(a_word)=>a_word.to_owned(),
None=>"".to_owned(),
}
Basically what I don't understand is this:
If I have a function:
fn do_something(a_str: &String)
{}
I have to call this function like so:
do_something(&some_string);
But with find in the example, even though find's closure takes its arg by ref I can pass that argument by value and it still works. In my opinion this is somewhat confusing.