Enum fluent_syntax::ast::Expression [−][src]
pub enum Expression<S> {
Select {
selector: InlineExpression<S>,
variants: Vec<Variant<S>>,
},
Inline(InlineExpression<S>),
}
Expand description
An expression that is either a select expression or an inline expression.
Example
use fluent_syntax::parser;
use fluent_syntax::ast;
let ftl = r#"
key = { $var ->
[key1] 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: "key"
},
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::Identifier {
name: "key1"
},
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
Select
Inline(InlineExpression<S>)
Tuple Fields
0: InlineExpression<S>
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 Expression<S> where
S: RefUnwindSafe,
impl<S> Send for Expression<S> where
S: Send,
impl<S> Sync for Expression<S> where
S: Sync,
impl<S> Unpin for Expression<S> where
S: Unpin,
impl<S> UnwindSafe for Expression<S> where
S: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more