fluent4rs 2.3.1

Parser / codec for [Fluent FTL files](https://github.com/projectfluent/fluent/blob/master/spec/fluent.ebnf), written for [lingora](https://github.com/nigeleke/lingora) (a localization management program), and may be found to be useful outside of that context. It is not intended to replace any aspects of the [fluent-rs](https://github.com/projectfluent/fluent-rs) crate implemented by [Project Fluent](https://projectfluent.org/), and, for the majority of language translation needs, the reader is referred back to that crate.
Documentation
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

#[cfg(feature = "walker")]
use crate::walker::{Visitor, Walkable};

/// [Junk](crate::ast::Junk) ::= junk_line (junk_line - "#" - "-" - [a-zA-Z])*
///
/// Junk represents unparsed content.
///
/// Junk is parsed line-by-line until a line is found which looks like it might
/// be a beginning of a new message, term, or a comment. Any whitespace
/// following a broken Entry is also considered part of Junk.
///
/// [Parser::parse](crate::parser::Parser::parse) treats Junk as a
/// [Fluent4rsError](crate::error::Fluent4rsError).
///
/// [Parser::parse_with_junk](crate::parser::Parser::parse_with_junk) will return [Junk](crate::ast::Junk)
/// in the [Resource](crate::ast::Resource).
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "hash", derive(Eq, PartialOrd, Ord, Hash))]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
pub struct Junk(Vec<String>);

impl From<&[String]> for Junk {
    fn from(value: &[String]) -> Self {
        Self(Vec::from(value))
    }
}

#[cfg(feature = "walker")]
impl Walkable for Junk {
    fn walk(&self, visitor: &mut dyn Visitor) {
        visitor.visit_junk(self);
    }
}

impl std::fmt::Display for Junk {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        let value = self
            .0
            .iter()
            .map(|l| l.to_string())
            .collect::<Vec<_>>()
            .join("");
        write!(f, "{value}")
    }
}