Apply `f: F` to create a rendering context of type `C` and render the given tree `t: T` within that context. # Panics Panics if the [`DisplayText::fmt_text`] call returns a [`fmt::Error`].
(t: &'a T, f: F)
| 272 | /// |
| 273 | /// Panics if the [`DisplayText::fmt_text`] call returns a [`fmt::Error`]. |
| 274 | pub fn text_string_at<'a, T: DisplayText<C>, C, F: Fn() -> C>(t: &'a T, f: F) -> String { |
| 275 | struct TextStringAt<'a, T, C, F: Fn() -> C> { |
| 276 | t: &'a T, |
| 277 | f: F, |
| 278 | } |
| 279 | |
| 280 | impl<T: DisplayText<C>, C, F: Fn() -> C> DisplayText<()> for TextStringAt<'_, T, C, F> { |
| 281 | fn fmt_text(&self, f: &mut fmt::Formatter<'_>, _ctx: &mut ()) -> fmt::Result { |
| 282 | let mut ctx = (self.f)(); |
| 283 | self.t.fmt_text(f, &mut ctx) |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | text_string(&TextStringAt { t, f }) |
| 288 | } |