Skip to main content

Statement

Enum Statement 

Source
pub enum Statement {
Show 14 variants Class(Class), Annotated(Annotated), Assign(Assign), Function(Function), Set { place: Expr, value: Expr, }, Expr(Expr), If { condition: Expr, then: Vec<Statement>, otherwise: Option<Vec<Statement>>, }, For { counter: Ident, bound: Expr, body: Vec<Statement>, }, While { condition: Expr, body: Vec<Statement>, }, Break, Return(Option<Expr>), Comment(Doc), Pass, Verbatim(String),
}
Expand description

One statement of a module or a class body.

Variants§

§

Class(Class)

A class definition.

§

Annotated(Annotated)

name: Type or name: Type = value — an annotated binding.

One node for a dataclass field, a Final constant and a bitset’s bitfield: Python spells all three the same way, and a tree that distinguished them would be recording the rule’s intent rather than the syntax.

§

Assign(Assign)

name = value — a binding with no annotation.

What a type alias and an enumeration member take: RED = 0 inside an enum.IntEnum is a member and RED: int = 0 is not, so the two forms are not interchangeable.

§

Function(Function)

A function definition.

§

Set

place = value — a store into somewhere that already exists.

v.field = x, v[i] = x, zd_wire = 3. Distinct from Statement::Assign for the reason the module documentation gives: a binding introduces a name and a store does not, and only the first of the two may appear where an enumeration member is read off the class body.

Fields

§place: Expr

Where the value goes.

§value: Expr

The value.

§

Expr(Expr)

An expression evaluated for its effect.

What a call to the runtime is: w.write_u32(v.x). Python has no (void) cast and no discarded-result diagnostic, so a value the generated code reads and does not keep is written as the call and nothing else.

§

If

if condition: ... [else: ...]

No elif. A chain is an else whose body is one more Statement::If, which is what elif abbreviates and what the codec walk builds; a separate arm would be a second spelling of one tree.

Fields

§condition: Expr

The condition.

§then: Vec<Statement>

The body taken when it holds; never empty.

§otherwise: Option<Vec<Statement>>

The body taken when it does not.

§

For

for counter in range(bound): ...

A counted loop and not the general for x in y. The codec walk’s CodecTarget::count_up asks for a count from zero and nothing else; a tree that could hold any iterable would be recording a loop this column never writes.

Fields

§counter: Ident

The induction variable.

§bound: Expr

The exclusive bound.

§body: Vec<Statement>

The body; never empty.

§

While

while condition: ...

Fields

§condition: Expr

The condition.

§body: Vec<Statement>

The body; never empty.

§

Break

break.

§

Return(Option<Expr>)

return, with or without a value.

§

Comment(Doc)

A # comment on lines of its own.

§

Pass

pass.

A body has to hold something. A rule that produced an empty class emits this rather than leaving the renderer to notice, because a renderer that inserted it would be deciding what the tree says.

§

Verbatim(String)

@verbatim text, copied into the output unchanged — OMG IDL 4.2 §8.3.5.1 asks for the text “verbatim”, so raw lines and never a comment. At the indentation of the suite it stands in.

Trait Implementations§

Source§

impl Clone for Statement

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 Statement

Source§

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

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

impl Eq for Statement

Source§

impl PartialEq for Statement

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 Statement

Auto Trait Implementations§

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.