<commit_before>use std::io;

use crate::{
    Command, Header, IdCode, ReferenceIndex, Scope, ScopeItem, ScopeType, SimulationCommand,
    TimescaleUnit, Value, Var, VarType,
};

/// Struct wrapping an `io::Write` with methods for writing VCD commands and data.
pub struct Writer<'w> {
    writer: &'w mut dyn io::Write,
    next_id_code: IdCode,
    scope_depth: usize,
}

impl<'s> Writer<'s> {
    /// Creates a Writer, wrapping an io::Write.
    ///
    /// ```
    /// let mut buf = Vec::new();
    /// let mut vcd = vcd::Writer::new(&mut buf);
    /// ```
    pub fn new(writer: &mut dyn io::Write) -> Writer<'_> {
        Writer {
            writer,
            next_id_code: IdCode::FIRST,
            scope_depth: 0,
        }
    }

    /// Writes a complete header with the fields from a `Header` struct from the parser.<commit_msg>Writer: Take io::Write directly, not a mutable reference<commit_after>use std::io;

use crate::{
    Command, Header, IdCode, ReferenceIndex, Scope, ScopeItem, ScopeType, SimulationCommand,
    TimescaleUnit, Value, Var, VarType,
};

/// Struct wrapping an `io::Write` with methods for writing VCD commands and data.
pub struct Writer<W: io::Write> {
    writer: W,
    next_id_code: IdCode,
    scope_depth: usize,
}

impl<W: io::Write> Writer<W> {
    /// Creates a Writer, wrapping an io::Write.
    ///
    /// ```
    /// let mut buf = Vec::new();
    /// let mut vcd = vcd::Writer::new(&mut buf);
    /// ```
    pub fn new(writer: W) -> Writer<W> {
        Writer {
            writer,
            next_id_code: IdCode::FIRST,
            scope_depth: 0,
        }
    }

    /// Writes a complete header with the fields from a `Header` struct from the parser.
{'fraction_non_alphanumeric': 0.14444444444444443, 'fraction_numerical': 0.0011695906432748538, 'mean_word_length': 2.4705882352941178, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7167771', 'n_tokens_mistral': 548, 'n_tokens_neox': 546, 'n_words': 171}