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};

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

/// [NamedArgument](crate::ast::NamedArgument) ::= [Identifier](crate::ast::Identifier) blank? ":" blank? ([StringLiteral](crate::ast::StringLiteral) | [NumberLiteral](crate::ast::NumberLiteral))
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "hash", derive(Eq, PartialOrd, Ord, Hash))]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
pub struct NamedArgument {
    identifier: Identifier,
    literal: Literal,
}

impl NamedArgument {
    /// Constructs a new `NamedArgument` representing a named (keyword) argument in a Fluent function call.
    ///
    /// # Arguments
    /// * `identifier` - The name of the argument (e.g., `style`, `month`, `minimumFractionDigits`).
    /// * `literal` - The literal value assigned to the argument. Typically a string or number.
    pub fn new(identifier: Identifier, literal: Literal) -> Self {
        Self {
            identifier,
            literal,
        }
    }

    /// Returns a reference to the identifier (name) of this named argument.
    pub fn identifier(&self) -> &Identifier {
        &self.identifier
    }
}

#[cfg(feature = "walker")]
impl Walkable for NamedArgument {
    fn walk(&self, visitor: &mut dyn Visitor) {
        visitor.visit_named_argument(self);
        Walker::walk(&self.identifier, visitor);
        Walker::walk(&self.literal, visitor);
    }
}

impl std::fmt::Display for NamedArgument {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}: {}", self.identifier, self.literal)
    }
}