pub enum ContentRef {
Argument(usize),
ArgumentNamed(String),
Body,
Node(NodeId),
Synthesized(Arc<NodeTree<Flm>>),
}Expand description
Document content that an aspect returns: a reference to content of the node the aspect was asked about (one of its arguments, its body, or one node of the same tree) or, for content that no node holds by itself, a small tree the aspect built.
An aspect refers to content wherever it can, for the reason given in the
module documentation. A consumer reads a
reference on the node that the aspect was asked about, with
ContentRef::nodes; a ContentRef::Synthesized tree is read as it is.
§Comparing two references
Two references are equal when they designate the same content. Two
synthesized trees are equal only when they are the same tree, shared
through one pointer (as the lists feature shares the one bullet tree it
builds per configured bullet with every item), and never because two trees
built separately hold the same text: a tree holds spans, sources and
parsing states that cannot be compared, and nothing in the library compares
content by its text. The hash of a ContentRef::Synthesized covers the
variant alone, so that it depends on no memory address and is the same on
every run.
Variants§
Argument(usize)
The content of the argument at this position, counted from zero in the order the arguments are written at the call.
ArgumentNamed(String)
The content of the argument with this name.
Body
The node’s body: the content of an environment, or of a command that takes a body.
Node(NodeId)
One node of the same tree, by its identifier: the node itself, one of its descendants, or any other node of that tree.
Synthesized(Arc<NodeTree<Flm>>)
Content that no node of the tree holds by itself, built by the aspect as
a small tree of its own: the bullet that a list’s configuration places
beside its items, or the value Custom of tag=Custom, which shares a
run of characters with its key.
The tree has the shape of a synthesized value built by copying
(crate::lang::copy): its root is a list node that holds the content
and adds nothing of its own (no delimiters, no text), so the content is
read as written inside it. A consumer uses the tree like a synthesized
value copied out of the document (the references feature shows it
where a reference to the point shows content); the tree is not part of
the document’s own trees.
An aspect that returns the same content for many points builds it once and shares it: the lists feature builds one tree per configured bullet when the registry is built. See comparing two references for how two such trees compare.
Implementations§
Source§impl ContentRef
impl ContentRef
Sourcepub fn nodes<'t>(
&'t self,
node: &NodeRef<'t, Flm>,
) -> Option<Vec<NodeRef<'t, Flm>>>
pub fn nodes<'t>( &'t self, node: &NodeRef<'t, Flm>, ) -> Option<Vec<NodeRef<'t, Flm>>>
The nodes this reference designates, read on node, the node whose
aspect returned the reference: the content of an argument, the body, or
one node of the tree; for ContentRef::Synthesized, the children of
the root of the tree it carries.
Returns None when the reference does not apply to node: an argument
that is absent or does not exist, no body, or no node with that
identifier in the tree.
Trait Implementations§
Source§impl Clone for ContentRef
impl Clone for ContentRef
Source§impl Debug for ContentRef
impl Debug for ContentRef
impl Eq for ContentRef
Source§impl Hash for ContentRef
impl Hash for ContentRef
Auto Trait Implementations§
impl !RefUnwindSafe for ContentRef
impl !UnwindSafe for ContentRef
impl Forget for ContentRef
impl Freeze for ContentRef
impl Move for ContentRef
impl Send for ContentRef
impl Sync for ContentRef
impl Unpin for ContentRef
impl UnsafeUnpin for ContentRefwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const ArcInner<NodeTree<Flm>> is !null: UnsafeUnpin,
PhantomData<ArcInner<NodeTree<Flm>>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more