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: snapshot_builder.rs
    path of file: ./repos/tools/crates/rome_formatter_test/src
    
    the code of the file until where you have to start completion: use rome_diagnostics::console::fmt::{Formatter, Termcolor};
use rome_diagnostics::console::markup;
use rome_diagnostics::PrintDiagnostic;
use rome_diag
    
    pub fn with_errors(mut self, parsed: &AnyParse, parse_input: &str) -> Self {
        if !parsed.has_errors() {
            return self;
        }

        let file_name = self.input_file.file_name().and_then(OsStr::to_str).unwrap();

        let mut buffer = termcolor::Buffer::no_color();

        for diagnostic in parsed.diagnostics() {
            let error = diagnostic
                .clone()
                .with_file_path(file_name)
                .with_file_source_code(parse_input);
            Formatter::new(&mut Termcolor(&mut buffer))
                .write_markup(markup! {
                    {PrintDiagnostic::verbose(&error)}
                })
                .expect("failed to emit diagnostic");
        }

        writeln!(self.snapshot, "# Errors").unwrap();
        writeln!(self.snapshot, "```").unwrap();
        writeln!(
            self.snapshot,
            "{}",
            std::str::from_utf8(buffer.as_slice()).expect("non utf8 in error buffer")
        )
        .unwrap();
        writeln!(self.snapshot, "```").unwrap();
        writeln!(self.snapshot).unwrap();

        self
    }