github_actions_expressions/
identifier.rs

1//! Identifiers.
2
3/// Represents a single identifier in a GitHub Actions expression,
4/// i.e. a single context component.
5///
6/// Identifiers are case-insensitive.
7#[derive(Debug)]
8pub struct Identifier<'src>(pub(crate) &'src str);
9
10impl Identifier<'_> {
11    /// Returns the identifier as a string slice, as it appears in the
12    /// expression.
13    ///
14    /// Important: identifiers are case-insensitive, so this should not
15    /// be used for comparisons.
16    pub fn as_str(&self) -> &str {
17        self.0
18    }
19}
20
21impl PartialEq for Identifier<'_> {
22    fn eq(&self, other: &Self) -> bool {
23        self.0.eq_ignore_ascii_case(other.0)
24    }
25}
26
27impl PartialEq<str> for Identifier<'_> {
28    fn eq(&self, other: &str) -> bool {
29        self.0.eq_ignore_ascii_case(other)
30    }
31}