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: project_merge_rule.rs
    path of file: ./repos/risingwave/src/frontend/src/optimizer/rule
    
    the code of the file until where you have to start completion: // Copyright 2024 RisingWave 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
    
    fn apply(&self, plan: PlanRef) -> Option<PlanRef> {
        let outer_project: &LogicalProject = plan.as_logical_project()?;
        let input = outer_project.input();
        let inner_project: &LogicalProject = input.as_logical_project()?;

        let mut input_ref_counter = InputRefCounter::default();
        for expr in outer_project.exprs() {
            input_ref_counter.visit_expr(expr);
        }
        // bail out if it is a project generated by `CommonSubExprExtractRule`.
        for (index, count) in &input_ref_counter.counter {
            if *count > 1 && matches!(inner_project.exprs()[*index], ExprImpl::FunctionCall(_)) {
                return None;
            }
        }

        let mut subst = Substitute {
            mapping: inner_project.exprs().clone(),
        };
        let exprs = outer_project
            .exprs()
            .iter()
            .cloned()
            .map(|expr| subst.rewrite_expr(expr))
            .collect();
        Some(LogicalProject::new(inner_project.input(), exprs).into())
    }