Рекурсивная функция, если оператор не соответствует типам в Rust
fn recursive_binary_search<T: Ord>(list: &mut [T], target: T) -> bool {
if list.len() < 1 {
return false;
}
let guess = list.len() / 2;
if target == list[guess] {
return true;
} else if list[guess] > target {
return recursive_binary_search(&mut list[0..guess], target);
} else if list[guess] < target {
return recursive_binary_search(&mut list[guess..list.len()], target);
}
}
компилятор выдает ошибкуif target == list[guess]
поговорка
src/main.rs:33:5: 39:6 error: mismatched types [E0308]
src/main.rs:33 if target == list[guess] {
^
src/main.rs:33:5: 39:6 help: run `rustc --explain E0308` to see a detailed explanation
src/main.rs:33:5: 39:6 note: expected type `bool`
src/main.rs:33:5: 39:6 note: found type `()`
error: aborting due to previous error
Я не могу понять, как переписать эту функцию, чтобы удовлетворить проверку типов. Я предполагаю, что это потому, что у меня установлен тип возвращаемого значения bool и есть вызов функции возврата?