stylex_transform/shared/enums/data_structures/
fn_result.rs1use swc_core::ecma::ast::Expr;
2
3use crate::shared::utils::core::js_to_expr::NestedStringObject;
4
5#[derive(Debug, PartialEq, Clone)]
6pub(crate) enum FnResult {
7 Attrs(NestedStringObject),
8 Props(NestedStringObject),
9 Stylex(Expr),
10}
11
12impl FnResult {
13 pub(crate) fn as_props(&self) -> Option<&NestedStringObject> {
14 match self {
15 FnResult::Props(props) => Some(props),
16 _ => None,
17 }
18 }
19
20 #[cfg(test)]
21 pub(crate) fn as_stylex(&self) -> Option<&Expr> {
22 match self {
23 FnResult::Stylex(expr) => Some(expr),
24 _ => None,
25 }
26 }
27
28 #[cfg(test)]
29 pub(crate) fn as_attrs(&self) -> Option<&NestedStringObject> {
30 match self {
31 FnResult::Attrs(attrs) => Some(attrs),
32 _ => None,
33 }
34 }
35}