(self, f: F, who: Option<&str>, expected: S2)
| 134 | |
| 135 | impl 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. |
no test coverage detected