Recursive-Funktion, wenn die Anweisung in Rust @ nicht übereinstim

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);
    }
}

der Compiler wirft einen Fehler aufif target == list[guess] Sprichwor

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

Ich kann nicht herausfinden, wie diese Funktion umgeschrieben wird, um die Typprüfung zu erfüllen. Ich nehme an, es liegt daran, dass ich den Rückgabetyp auf bool gesetzt habe und es einen Rückgabefunktionsaufruf gibt?

Antworten auf die Frage(4)

Ihre Antwort auf die Frage