Skip to main content

render_path

Function render_path 

Source
pub fn render_path(path: &[Seg]) -> String
Expand description

A concrete path as text: keys joined by ., an index as [i], and the empty string for the document root — meta.author, audience[1], items[0].title. This is how fig’s own Warning addresses a node and how a Finding does, so the three agree.

A key containing . or [ renders ambiguously, exactly as it does in fig; the grammar has no quoting, and this crate does not add one on its own.

use fig_schema::{Seg, render_path};

let path = [Seg::Key("audience".into()), Seg::Index(1)];
assert_eq!(render_path(&path), "audience[1]");
assert_eq!(render_path(&[]), "");