MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / text_string_at

Function text_string_at

src/repr/src/explain/text.rs:274–288  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

272///
273/// Panics if the [`DisplayText::fmt_text`] call returns a [`fmt::Error`].
274pub 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}

Callers 4

debug_explainMethod · 0.85
debug_explainMethod · 0.85
handle_explainFunction · 0.85

Calls 1

text_stringFunction · 0.70

Tested by 2

handle_explainFunction · 0.68