pub struct Fragment { /* private fields */ }Expand description
A fragment: one piece of source as the parser delivered it, with its tree,
the source it came from, the diagnostics of the parse, and the layout of its
top level (FragmentLayout).
The tree is exactly what the parse delivered, source comments included. Expanding user definitions and building block structure are rewrite stages of a run, and the trees they produce are stored by the run, apart from the fragment. Because the fragment keeps the parse as written, one shared fragment can be used by several documents with different configurations, and a tool can recover the author’s own text from it.
A fragment is shared as Arc<Fragment> and has no identifier: its
identity is the pointer, and within one document each placement of it is
identified by a TreeId. Create one with
parse_fragment, or with Fragment::new
from a tree obtained some other way.
Implementations§
Source§impl Fragment
impl Fragment
Sourcepub fn new(
source: Arc<FlmSource>,
tree: Arc<NodeTree<Flm>>,
diags: FlmDiagnostics,
layout: FragmentLayout,
) -> Fragment
pub fn new( source: Arc<FlmSource>, tree: Arc<NodeTree<Flm>>, diags: FlmDiagnostics, layout: FragmentLayout, ) -> Fragment
A fragment holding the parsed tree tree, the source it was parsed
from, the diagnostics of the parse and the layout of its top level.
parse_fragment is the usual way to
obtain a fragment; this constructor is for a tree built or read back
from storage elsewhere. No check is made that the parts belong
together.
Sourcepub fn source(&self) -> &Arc<FlmSource> ⓘ
pub fn source(&self) -> &Arc<FlmSource> ⓘ
The source the tree was parsed from; its origin (such as a file name) is what diagnostics report.
Sourcepub fn diags(&self) -> &FlmDiagnostics
pub fn diags(&self) -> &FlmDiagnostics
The diagnostics the parse produced. Diagnostics reported later, while stages run, are kept by the run instead.
Sourcepub fn layout(&self) -> FragmentLayout
pub fn layout(&self) -> FragmentLayout
How the top level is laid out when block structure is built.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Fragment
impl !UnwindSafe for Fragment
impl Forget for Fragment
impl Freeze for Fragment
impl Move for Fragment
impl Send for Fragment
impl Sync for Fragment
impl Unpin for Fragment
impl UnsafeUnpin for Fragmentwhere
*const ArcInner<Source<FlmOrigin>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Source<FlmOrigin>>>: UnsafeUnpin,
*const ArcInner<NodeTree<Flm>> is !null: UnsafeUnpin,
PhantomData<ArcInner<NodeTree<Flm>>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<Diagnostic<FlmOrigin>>: 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> 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