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: page_index.rs
    path of file: ./repos/databend/src/query/storages/common/index/src
    
    the code of the file until where you have to start completion: // Copyright 2021 Datafuse Labs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License 
    
    pub fn apply(&self, stats: &Option<ClusterStatistics>) -> Result<(bool, Option<Range<usize>>)> {
        let stats = match stats {
            Some(stats) => stats,
            None => return Ok((true, None)),
        };
        let min_values: Vec<Scalar> = match stats.pages {
            Some(ref pages) => pages.clone(),
            None => return Ok((true, None)),
        };

        let max_value = Scalar::Tuple(stats.max().clone());

        if self.cluster_key_id != stats.cluster_key_id {
            return Ok((true, None));
        }

        let pages = min_values.len();
        let mut start = 0;
        let mut end = pages - 1;

        while start <= end {
            let min_value = &min_values[start];
            let max_value = if start + 1 < pages {
                &min_values[start + 1]
            } else {
                &max_value
            };

            if self.eval_single_page(min_value, max_value)? {
                break;
            }
            start += 1;
        }

        while end >= start {
            let min_value = &min_values[end];
            let max_value = if end + 1 < pages {
                &min_values[end + 1]
            } else {
                &max_value
            };

            if self.eval_single_page(min_value, max_value)? {
                break;
            }
            end -= 1;
        }

        // no page is pruned
        if start + pages == end + 1 {
            return Ok((true, None));
        }

        if start > end {
            Ok((false, None))
        } else {
            Ok((true, Some(start..end + 1)))
        }
    }