Skip to main content

Class

Struct Class 

Source
pub struct Class {
    pub name: Option<Ident>,
    pub super_class: Option<Box<Expr>>,
    pub elements: Vec<ClassElement>,
    pub span: Span,
    pub body_end: Position,
}
Expand description

A class body.

Fields§

§name: Option<Ident>

Class name: required for declarations, optional for expressions.

§super_class: Option<Box<Expr>>

extends clause.

§elements: Vec<ClassElement>

Members, in source order.

§span: Span

Source range.

§body_end: Position

The closing } of the body.

A class that writes no constructor still gets one, and the reference creates that synthetic function at the closing brace: js_parse_class_default_ctor runs with the } as its current token and hands s->token.ptr to js_new_function_def. The position is the function’s own source_pos, which is the first entry of its line table — so class B extends BigInt {} constructed as new B(1) reports its frame at the }, not at class. span.end cannot stand in: it is one past the brace, and the brace may be the last character of a line.

Implementations§

Source§

impl Class

Source

pub fn has_own_name(&self) -> bool

Whether the class body itself defines name, which an anonymous class then keeps.

class { static name(){} } has an own name property, so assigning one from the binding would either fail or be shadowed — NamedEvaluation checks for it and leaves the class alone.

Trait Implementations§

Source§

impl Clone for Class

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Class

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Class

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Class

Auto Trait Implementations§

§

impl Forget for Class

§

impl Freeze for Class

§

impl Move for Class

§

impl RefUnwindSafe for Class

§

impl Send for Class
where RawVecInner: Send, BoxRaw<Expr>: Send, BoxRaw<Function>: Send, BoxRaw<Stmt>: Send, BoxRaw<RestElement>: Send, BoxRaw<Pattern>: Send, BoxRaw<MemberPattern>: Send, BoxRaw<Class>: Send, BoxRaw<ImportDecl>: Send, BoxRaw<ExportDecl>: Send,

§

impl Sync for Class
where RawVecInner: Sync, BoxRaw<Expr>: Sync, BoxRaw<Function>: Sync, BoxRaw<Stmt>: Sync, BoxRaw<RestElement>: Sync, BoxRaw<Pattern>: Sync, BoxRaw<MemberPattern>: Sync, BoxRaw<Class>: Sync, BoxRaw<ImportDecl>: Sync, BoxRaw<ExportDecl>: Sync,

§

impl Unpin for Class

§

impl UnsafeUnpin for Class

§

impl UnwindSafe for Class
where RawVecInner: UnwindSafe, BoxRaw<Expr>: UnwindSafe, BoxRaw<Function>: UnwindSafe, BoxRaw<Stmt>: UnwindSafe, BoxRaw<RestElement>: UnwindSafe, BoxRaw<Pattern>: UnwindSafe, BoxRaw<MemberPattern>: UnwindSafe, BoxRaw<Class>: UnwindSafe, BoxRaw<ImportDecl>: UnwindSafe, BoxRaw<ExportDecl>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.