Enum fluent_syntax::ast::VariantKey [−][src]
pub enum VariantKey<S> {
Identifier {
name: S,
},
NumberLiteral {
value: S,
},
}
Expand description
A key of a Variant
.
Variant key can be either an identifier or a number.
Example
use fluent_syntax::parser;
use fluent_syntax::ast;
let ftl = r#"
hello-world = { $var ->
[0] Value 1
*[other] Value 2
}
"#;
let resource = parser::parse(ftl)
.expect("Failed to parse an FTL resource.");
assert_eq!(
resource,
ast::Resource {
body: vec![
ast::Entry::Message(ast::Message {
id: ast::Identifier {
name: "hello-world"
},
value: Some(ast::Pattern {
elements: vec![
ast::PatternElement::Placeable {
expression: ast::Expression::Select {
selector: ast::InlineExpression::VariableReference {
id: ast::Identifier { name: "var" },
},
variants: vec![
ast::Variant {
key: ast::VariantKey::NumberLiteral {
value: "0"
},
value: ast::Pattern {
elements: vec![
ast::PatternElement::TextElement {
value: "Value 1",
}
]
},
default: false,
},
ast::Variant {
key: ast::VariantKey::Identifier {
name: "other"
},
value: ast::Pattern {
elements: vec![
ast::PatternElement::TextElement {
value: "Value 2",
}
]
},
default: true,
},
]
}
}
]
}),
attributes: vec![],
comment: None,
}),
]
}
);
Variants
Identifier
NumberLiteral
Trait Implementations
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl<S> RefUnwindSafe for VariantKey<S> where
S: RefUnwindSafe,
impl<S> Send for VariantKey<S> where
S: Send,
impl<S> Sync for VariantKey<S> where
S: Sync,
impl<S> Unpin for VariantKey<S> where
S: Unpin,
impl<S> UnwindSafe for VariantKey<S> where
S: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more