Enum swc_html_ast::Child
source · pub enum Child {
DocumentType(DocumentType),
Element(Element),
Text(Text),
Comment(Comment),
}
Variants§
Implementations§
source§impl Child
impl Child
sourcepub const fn is_document_type(&self) -> bool
pub const fn is_document_type(&self) -> bool
Returns true
if self
is of variant DocumentType
.
sourcepub fn as_document_type(&self) -> Option<&DocumentType>
pub fn as_document_type(&self) -> Option<&DocumentType>
Returns Some
if self
is a reference of variant DocumentType
, and None
otherwise.
sourcepub fn as_mut_document_type(&mut self) -> Option<&mut DocumentType>
pub fn as_mut_document_type(&mut self) -> Option<&mut DocumentType>
Returns Some
if self
is a mutable reference of variant DocumentType
, and None
otherwise.
sourcepub fn expect_document_type(self) -> DocumentTypewhere
Self: Debug,
pub fn expect_document_type(self) -> DocumentTypewhere
Self: Debug,
Unwraps the value, yielding the content of DocumentType
.
Panics
Panics if the value is not DocumentType
, with a panic message including the content of self
.
sourcepub fn document_type(self) -> Option<DocumentType>
pub fn document_type(self) -> Option<DocumentType>
Returns Some
if self
is of variant DocumentType
, and None
otherwise.
sourcepub const fn is_element(&self) -> bool
pub const fn is_element(&self) -> bool
Returns true
if self
is of variant Element
.
sourcepub fn as_element(&self) -> Option<&Element>
pub fn as_element(&self) -> Option<&Element>
Returns Some
if self
is a reference of variant Element
, and None
otherwise.
sourcepub fn as_mut_element(&mut self) -> Option<&mut Element>
pub fn as_mut_element(&mut self) -> Option<&mut Element>
Returns Some
if self
is a mutable reference of variant Element
, and None
otherwise.
sourcepub fn expect_element(self) -> Elementwhere
Self: Debug,
pub fn expect_element(self) -> Elementwhere
Self: Debug,
sourcepub fn element(self) -> Option<Element>
pub fn element(self) -> Option<Element>
Returns Some
if self
is of variant Element
, and None
otherwise.
sourcepub fn as_text(&self) -> Option<&Text>
pub fn as_text(&self) -> Option<&Text>
Returns Some
if self
is a reference of variant Text
, and None
otherwise.
sourcepub fn as_mut_text(&mut self) -> Option<&mut Text>
pub fn as_mut_text(&mut self) -> Option<&mut Text>
Returns Some
if self
is a mutable reference of variant Text
, and None
otherwise.
sourcepub fn expect_text(self) -> Textwhere
Self: Debug,
pub fn expect_text(self) -> Textwhere
Self: Debug,
sourcepub const fn is_comment(&self) -> bool
pub const fn is_comment(&self) -> bool
Returns true
if self
is of variant Comment
.
sourcepub fn as_comment(&self) -> Option<&Comment>
pub fn as_comment(&self) -> Option<&Comment>
Returns Some
if self
is a reference of variant Comment
, and None
otherwise.
sourcepub fn as_mut_comment(&mut self) -> Option<&mut Comment>
pub fn as_mut_comment(&mut self) -> Option<&mut Comment>
Returns Some
if self
is a mutable reference of variant Comment
, and None
otherwise.