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: pattern_match_or.rs
    path of file: ./repos/ruff/crates/ruff_python_formatter/src/pattern
    
    the code of the file until where you have to start completion: use ruff_formatter::write;
use ruff_python_ast::AnyNodeRef;
use ruff_python_ast::PatternMatchOr;

use crate::comments::leading_comments;
use crate::expression::parentheses::{
    in_parentheses_only_soft_line_break_or_space, NeedsParentheses, OptionalParentheses,
};
use crate::prelude::*;

#[derive(Default)]
pub struct FormatPatternMatchOr;

impl FormatNodeRule<PatternMatchOr> for FormatPatternMatchOr {
    fn fmt_fields(&self, item: &PatternMatchOr, f: &mut PyFormatter) -> FormatResult<()> {
        let PatternMatchOr { range: _, patterns } = item;
        let inner = format_with(|f: &mut PyFormatter| {
            let mut patterns = patterns.iter();
            let comments = f.context().comments().clone();

            let Some(first) = patterns.next() else {
                return Ok(());
            };

            first.format().fmt(f)?;

            for pattern in patterns {
                let leading_value_comments = comments.leading(pattern);
   
    
    fn fmt_fields(&self, item: &PatternMatchOr, f: &mut PyFormatter) -> FormatResult<()> {
        let PatternMatchOr { range: _, patterns } = item;
        let inner = format_with(|f: &mut PyFormatter| {
            let mut patterns = patterns.iter();
            let comments = f.context().comments().clone();

            let Some(first) = patterns.next() else {
                return Ok(());
            };

            first.format().fmt(f)?;

            for pattern in patterns {
                let leading_value_comments = comments.leading(pattern);
                // Format the expressions leading comments **before** the operator
                if leading_value_comments.is_empty() {
                    write!(f, [in_parentheses_only_soft_line_break_or_space()])?;
                } else {
                    write!(
                        f,
                        [hard_line_break(), leading_comments(leading_value_comments)]
                    )?;
                }
                write!(f, [token("|"), space(), pattern.format()])?;
            }

            Ok(())
        });

        inner.fmt(f)
    }