pub struct Document(/* private fields */);Expand description
The typed root of a parsed document.
Wraps the SyntaxKind::Root node and exposes the single top-level value
plus any leading extension attributes.
Implementations§
Source§impl Document
impl Document
Sourcepub fn cast(node: SyntaxNode) -> Option<Self>
pub fn cast(node: SyntaxNode) -> Option<Self>
Wrap a SyntaxKind::Root node, or None for any other kind.
Sourcepub fn syntax(&self) -> &SyntaxNode
pub fn syntax(&self) -> &SyntaxNode
The underlying root SyntaxNode.
Sourcepub fn value(&self) -> Option<Value>
pub fn value(&self) -> Option<Value>
The single top-level Value, if the document has one (absent for an
empty / trivia-only file).
Sourcepub fn extension_attrs(&self) -> impl Iterator<Item = ExtensionAttr> + '_
pub fn extension_attrs(&self) -> impl Iterator<Item = ExtensionAttr> + '_
The leading extension attributes #![enable(..)], in source order.
Trait Implementations§
impl Eq for Document
impl StructuralPartialEq for Document
Auto Trait Implementations§
impl !RefUnwindSafe for Document
impl !Send for Document
impl !Sync for Document
impl !UnwindSafe for Document
impl Freeze for Document
impl Unpin for Document
impl UnsafeUnpin for Document
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
Mutably borrows from an owned value. Read more