Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new method on core Expr #1428

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading