Skip to content

Commit

Permalink
new method on core Expr (#1428)
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Disselkoen <cdiss@amazon.com>
  • Loading branch information
cdisselkoen authored Jan 16, 2025
1 parent 3229927 commit a4ff416
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions cedar-policy-core/src/ast/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ impl<T> Expr<T> {
self.data
}

/// Consume the `Expr`, returning the `ExprKind`, `source_loc`, and stored
/// data.
pub fn into_parts(self) -> (ExprKind<T>, Option<Loc>, T) {
(self.expr_kind, self.source_loc, self.data)
}

/// Access the `Loc` stored on the `Expr`.
pub fn source_loc(&self) -> Option<&Loc> {
self.source_loc.as_ref()
Expand Down Expand Up @@ -1455,10 +1461,9 @@ impl<T: Default + Clone> expr_builder::ExprBuilder for ExprBuilder<T> {
}

impl<T> ExprBuilder<T> {
/// Internally used by the following methods to construct an `Expr`
/// containing the `data` and `source_loc` in this `ExprBuilder` with some
/// inner `ExprKind`.
fn with_expr_kind(self, expr_kind: ExprKind<T>) -> Expr<T> {
/// Construct an `Expr` containing the `data` and `source_loc` in this
/// `ExprBuilder` and the given `ExprKind`.
pub fn with_expr_kind(self, expr_kind: ExprKind<T>) -> Expr<T> {
Expr::new(expr_kind, self.source_loc, self.data)
}

Expand Down

0 comments on commit a4ff416

Please sign in to comment.