Skip to main content

write_between_bound

Function write_between_bound 

Source
fn write_between_bound<W: Write, T: AstInfo>(
    f: &mut AstFormatter<W>,
    bound: &Expr<T>,
)
Expand description

Write bound as a BETWEEN … AND … bound. The parser parses both bounds with parse_subexpr(Precedence::Like) (see Parser::parse_between), starting fresh with nothing to the bound’s left, so it walks the bound’s left spine and stops at the first operator binding at or below Like, leaving that operator outside the bound (x BETWEEN 1 IS NULL AND y parses 1 as the bound, then expects AND but finds IS). A bound is therefore safe bare only when its left edge binds strictly above Like. Use left_edge (not right_edge, which closes at ATOM for the right-closing IS NULL/= ANY (…)/IN (…) forms whose looseness is on the left). The parser wraps these bounds in Expr::Nested (which is ATOM, so it prints bare). This re-adds the parens for ASTs where that wrapper is absent.