Skip to content

Commit

Permalink
Implement Function return Spanned
Browse files Browse the repository at this point in the history
  • Loading branch information
flyingsilverfin committed Jan 30, 2025
1 parent ea9244f commit f0e1dd3
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions rust/schema/definable/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,17 @@ impl ReturnStream {
pub fn new(span: Option<Span>, vars: Vec<Variable>) -> Self {
Self { span, vars }
}

}

impl Spanned for ReturnStream {
fn span(&self) -> Option<Span> {
self.span
}
}

impl Pretty for ReturnStream {}

impl fmt::Display for ReturnStream {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
assert!(!self.vars.is_empty());
Expand All @@ -309,6 +318,14 @@ impl ReturnSingle {
}
}

impl Spanned for ReturnSingle {
fn span(&self) -> Option<Span> {
self.span
}
}

impl Pretty for ReturnSingle {}

impl fmt::Display for ReturnSingle {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
assert!(!self.vars.is_empty());
Expand Down Expand Up @@ -339,7 +356,16 @@ impl fmt::Display for SingleSelector {
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum ReturnReduction {
Check(Check),
Value(Vec<Reducer>),
Value(Vec<Reducer>, Option<Span>),
}

impl Spanned for ReturnReduction {
fn span(&self) -> Option<Span> {
match self {
ReturnReduction::Check(check) => check.span(),
ReturnReduction::Value(_, span) => *span,
}
}
}

impl Pretty for ReturnReduction {
Expand All @@ -352,7 +378,7 @@ impl fmt::Display for ReturnReduction {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Check(inner) => fmt::Display::fmt(inner, f),
Self::Value(inner) => {
Self::Value(inner, _) => {
write_joined!(f, ", ", inner)?;
Ok(())
}
Expand All @@ -371,6 +397,12 @@ impl Check {
}
}

impl Spanned for Check {
fn span(&self) -> Option<Span> {
self.span
}
}

impl Pretty for Check {}

impl fmt::Display for Check {
Expand Down

0 comments on commit f0e1dd3

Please sign in to comment.