MCPcopy Create free account
hub / github.com/PRQL/prql / try_cast

Method try_cast

prqlc/prqlc/src/semantic/mod.rs:136–148  ·  view source on GitHub ↗
(self, f: F, who: Option<&str>, expected: S2)

Source from the content-addressed store, hash-verified

134
135impl pl::Expr {
136 fn try_cast<T, F, S2: ToString>(self, f: F, who: Option<&str>, expected: S2) -> Result<T, Error>
137 where
138 F: FnOnce(pl::ExprKind) -> Result<T, pl::ExprKind>,
139 {
140 f(self.kind).map_err(|i| {
141 Error::new(Reason::Expected {
142 who: who.map(|s| s.to_string()),
143 expected: expected.to_string(),
144 found: format!("`{}`", write_pl(pl::Expr::new(i))),
145 })
146 .with_span(self.span)
147 })
148 }
149}
150
151/// Write a PL IR to string.

Callers 3

lower_table_refMethod · 0.80
resolve_special_funcMethod · 0.80
fold_exprMethod · 0.80

Calls 3

with_spanMethod · 0.80
mapMethod · 0.80
fFunction · 0.50

Tested by

no test coverage detected