You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: artefact_Binary_search_shared.rs
    path of file: ./repos/prusti-dev/prusti-tests/tests/verify_overflow/pass/rosetta/Binary_search
    
    the code of the file until where you have to start completion: // compile-flags: -Puse_more_complete_exhale=false

//! An adaptation of the example from
//! https://rosettacode.org/wiki/Binary_search#Rust
//!
//! The original example:
//! ```rust
//! use std::cmp::Ordering::*;
//! fn binary_search<T: Ord>(arr: &[T], elem: &T) -> Option<usize>
//! {
//!     let mut size = arr.len();
//!     let mut base = 0;
//!
//!     while size > 0 {
//!         size /= 2;
//!         let mid = base + size;
//!         base = match arr[mid].cmp(elem) {
//!             Less    => mid,
//!             Greater => base,
//!             Equal   => return Some(mid)
//!         };
//!     }
//!
//!     None
//! }
//! ```
//!
//! Changes:
/
    
fn binary_search<T: Ord>(arr: &VecWrapper<T>, elem: &T) -> UsizeOption {
    let mut size = arr.len();
    let mut base = 0;

    let mut result = UsizeOption::None;
    let mut continue_loop = size > 0;


    while continue_loop {
        body_invariant!(continue_loop == (size > 0 && result.is_none()));
        body_invariant!(base + size <= arr.len());
        let half = size / 2;
        let mid = base + half;

        let mid_element = arr.index(mid);
        let cmp_result = cmp(mid_element, elem);
        base = match cmp_result {
            Less    => {
                mid
            },
            Greater => {
                base
            },
            // Equal
            _   => {
                result = UsizeOption::Some(mid);
                base   // Just return anything because we are finished.
            }
        };

        size -= half;
        continue_loop = size > 0 && result.is_none();
    }

    result
}