Enum swc_ecma_ast::Pat
source · pub enum Pat {
Ident(BindingIdent),
Array(ArrayPat),
Rest(RestPat),
Object(ObjectPat),
Assign(AssignPat),
Invalid(Invalid),
Expr(Box<Expr>),
}
Variants§
Ident(BindingIdent)
Array(ArrayPat)
Rest(RestPat)
Object(ObjectPat)
Assign(AssignPat)
Invalid(Invalid)
Expr(Box<Expr>)
Only for for-in / for-of loops. This is syntactically valid.
Implementations§
source§impl Pat
impl Pat
sourcepub fn as_ident(&self) -> Option<&BindingIdent>
pub fn as_ident(&self) -> Option<&BindingIdent>
Returns Some
if self
is a reference of variant Ident
, and None
otherwise.
sourcepub fn as_mut_ident(&mut self) -> Option<&mut BindingIdent>
pub fn as_mut_ident(&mut self) -> Option<&mut BindingIdent>
Returns Some
if self
is a mutable reference of variant Ident
, and None
otherwise.
sourcepub fn expect_ident(self) -> BindingIdentwhere
Self: Debug,
pub fn expect_ident(self) -> BindingIdentwhere Self: Debug,
sourcepub fn ident(self) -> Option<BindingIdent>
pub fn ident(self) -> Option<BindingIdent>
Returns Some
if self
is of variant Ident
, and None
otherwise.
sourcepub fn as_array(&self) -> Option<&ArrayPat>
pub fn as_array(&self) -> Option<&ArrayPat>
Returns Some
if self
is a reference of variant Array
, and None
otherwise.
sourcepub fn as_mut_array(&mut self) -> Option<&mut ArrayPat>
pub fn as_mut_array(&mut self) -> Option<&mut ArrayPat>
Returns Some
if self
is a mutable reference of variant Array
, and None
otherwise.
sourcepub fn expect_array(self) -> ArrayPatwhere
Self: Debug,
pub fn expect_array(self) -> ArrayPatwhere Self: Debug,
sourcepub fn array(self) -> Option<ArrayPat>
pub fn array(self) -> Option<ArrayPat>
Returns Some
if self
is of variant Array
, and None
otherwise.
sourcepub fn as_rest(&self) -> Option<&RestPat>
pub fn as_rest(&self) -> Option<&RestPat>
Returns Some
if self
is a reference of variant Rest
, and None
otherwise.
sourcepub fn as_mut_rest(&mut self) -> Option<&mut RestPat>
pub fn as_mut_rest(&mut self) -> Option<&mut RestPat>
Returns Some
if self
is a mutable reference of variant Rest
, and None
otherwise.
sourcepub fn expect_rest(self) -> RestPatwhere
Self: Debug,
pub fn expect_rest(self) -> RestPatwhere Self: Debug,
sourcepub fn rest(self) -> Option<RestPat>
pub fn rest(self) -> Option<RestPat>
Returns Some
if self
is of variant Rest
, and None
otherwise.
sourcepub fn as_object(&self) -> Option<&ObjectPat>
pub fn as_object(&self) -> Option<&ObjectPat>
Returns Some
if self
is a reference of variant Object
, and None
otherwise.
sourcepub fn as_mut_object(&mut self) -> Option<&mut ObjectPat>
pub fn as_mut_object(&mut self) -> Option<&mut ObjectPat>
Returns Some
if self
is a mutable reference of variant Object
, and None
otherwise.
sourcepub fn expect_object(self) -> ObjectPatwhere
Self: Debug,
pub fn expect_object(self) -> ObjectPatwhere Self: Debug,
sourcepub fn object(self) -> Option<ObjectPat>
pub fn object(self) -> Option<ObjectPat>
Returns Some
if self
is of variant Object
, and None
otherwise.
sourcepub fn as_assign(&self) -> Option<&AssignPat>
pub fn as_assign(&self) -> Option<&AssignPat>
Returns Some
if self
is a reference of variant Assign
, and None
otherwise.
sourcepub fn as_mut_assign(&mut self) -> Option<&mut AssignPat>
pub fn as_mut_assign(&mut self) -> Option<&mut AssignPat>
Returns Some
if self
is a mutable reference of variant Assign
, and None
otherwise.
sourcepub fn expect_assign(self) -> AssignPatwhere
Self: Debug,
pub fn expect_assign(self) -> AssignPatwhere Self: Debug,
sourcepub fn assign(self) -> Option<AssignPat>
pub fn assign(self) -> Option<AssignPat>
Returns Some
if self
is of variant Assign
, and None
otherwise.
sourcepub const fn is_invalid(&self) -> bool
pub const fn is_invalid(&self) -> bool
Returns true
if self
is of variant Invalid
.
sourcepub fn as_invalid(&self) -> Option<&Invalid>
pub fn as_invalid(&self) -> Option<&Invalid>
Returns Some
if self
is a reference of variant Invalid
, and None
otherwise.
sourcepub fn as_mut_invalid(&mut self) -> Option<&mut Invalid>
pub fn as_mut_invalid(&mut self) -> Option<&mut Invalid>
Returns Some
if self
is a mutable reference of variant Invalid
, and None
otherwise.
sourcepub fn expect_invalid(self) -> Invalidwhere
Self: Debug,
pub fn expect_invalid(self) -> Invalidwhere Self: Debug,
sourcepub fn invalid(self) -> Option<Invalid>
pub fn invalid(self) -> Option<Invalid>
Returns Some
if self
is of variant Invalid
, and None
otherwise.
sourcepub fn as_expr(&self) -> Option<&Box<Expr>>
pub fn as_expr(&self) -> Option<&Box<Expr>>
Returns Some
if self
is a reference of variant Expr
, and None
otherwise.
sourcepub fn as_mut_expr(&mut self) -> Option<&mut Box<Expr>>
pub fn as_mut_expr(&mut self) -> Option<&mut Box<Expr>>
Returns Some
if self
is a mutable reference of variant Expr
, and None
otherwise.
sourcepub fn expect_expr(self) -> Box<Expr>where
Self: Debug,
pub fn expect_expr(self) -> Box<Expr>where Self: Debug,
Trait Implementations§
source§impl<'arbitrary> Arbitrary<'arbitrary> for Pat
impl<'arbitrary> Arbitrary<'arbitrary> for Pat
source§fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
Self
from the given unstructured data. Read moresource§fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
Self
from the entirety of the given
unstructured data. Read moresource§impl Archive for Pat
impl Archive for Pat
source§impl<'de> Deserialize<'de> for Pat
impl<'de> Deserialize<'de> for Pat
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl<__D> Deserialize<Pat, __D> for Archived<Pat>where
__D: SharedDeserializeRegistry + Fallible + ?Sized,
impl<__D> Deserialize<Pat, __D> for Archived<Pat>where __D: SharedDeserializeRegistry + Fallible + ?Sized,
source§impl EqIgnoreSpan for Pat
impl EqIgnoreSpan for Pat
fn eq_ignore_span(&self, other: &Self) -> bool
source§impl From<(Atom<JsWordStaticSet>, SyntaxContext)> for Box<Pat>
impl From<(Atom<JsWordStaticSet>, SyntaxContext)> for Box<Pat>
source§impl From<(Atom<JsWordStaticSet>, SyntaxContext)> for Pat
impl From<(Atom<JsWordStaticSet>, SyntaxContext)> for Pat
source§impl From<BindingIdent> for Pat
impl From<BindingIdent> for Pat
source§fn from(v: BindingIdent) -> Self
fn from(v: BindingIdent) -> Self
source§impl<__S> Serialize<__S> for Patwhere
__S: Serializer + ScratchSpace + SharedSerializeRegistry + Fallible + ?Sized,
impl<__S> Serialize<__S> for Patwhere __S: Serializer + ScratchSpace + SharedSerializeRegistry + Fallible + ?Sized,
impl Eq for Pat
impl StructuralEq for Pat
impl StructuralPartialEq for Pat
Auto Trait Implementations§
impl RefUnwindSafe for Pat
impl Send for Pat
impl Sync for Pat
impl Unpin for Pat
impl UnwindSafe for Pat
Blanket Implementations§
source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata
source§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere T: Archive,
§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive
, it may be unsized. Read more