Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
chip-so committed Feb 13, 2025
1 parent cccfb56 commit 63d36da
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions crates/aranya-policy-ast/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,27 @@ impl FactDefinition {
impl FieldDefinition {
/// Is this a hashable type (int, bool, string, or id)?
pub fn is_hashable(&self) -> bool {
matches!(self.field_type, VType::Int | VType::Bool | VType::String | VType::Id)
matches!(
self.field_type,
VType::Int | VType::Bool | VType::String | VType::Id
)
}
}

impl Expression {
/// Is this a literal expression?
pub fn is_literal(&self) -> bool {
match self {
Expression::Int(_) | Expression::String(_) | Expression::Bool(_) | Expression::EnumReference(_) => true,
Expression::Int(_)
| Expression::String(_)
| Expression::Bool(_)
| Expression::EnumReference(_) => true,
Expression::Optional(o) => match o {
Some(e) => e.is_literal(),
None => true,
}
},
Expression::NamedStruct(s) => s.fields.iter().all(|(_, e)| e.is_literal()),
_ => false,
}
}
}
}

0 comments on commit 63d36da

Please sign in to comment.