pub struct Trivia(/* private fields */);Expand description
Ordinary // comments, keyed by what they describe.
Keying by identity rather than by position is what lets the editor mutate a graph and save it without losing anybody’s notes: an untouched node keeps its comments wherever canonical ordering moves it.
This lives beside the IR rather than in the syntax crate for one reason: the keys are IR identities, and renaming a node has to update the table in the same operation that updates the graph. A table one layer above the code performing the rename cannot be kept in step with it.
/// comments are deliberately absent — those are semantic and live on
[Node::doc].
Implementations§
Source§impl Trivia
impl Trivia
pub fn get(&self, anchor: &Anchor) -> &[String]
Sourcepub fn add(&mut self, anchor: Anchor, comments: Vec<String>)
pub fn add(&mut self, anchor: Anchor, comments: Vec<String>)
Appends rather than replaces. Two identical wires drawn on two branches dedupe into one edge, but discarding one side’s explanation of it is the wrong half to throw away.