Skip to main content

ExtractionPlan

Struct ExtractionPlan 

Source
pub struct ExtractionPlan {
Show 15 fields pub lang: Lang, pub enclosing_function: String, pub parameters: Vec<String>, pub parameter_spellings: Vec<String>, pub returns: Vec<String>, pub return_type: Option<String>, pub returns_declared_mut: bool, pub local_declarations: Vec<String>, pub returns_need_declaration: bool, pub start_byte: usize, pub end_byte: usize, pub indent: String, pub insert_byte: usize, pub enclosing_indent: String, pub indent_unit: String,
}
Expand description

A derived extraction, ready to be spelled by a language emitter.

Fields§

§lang: Lang

The language the plan was derived from; the emitter reads it back so a plan cannot be rendered with another language’s spelling.

§enclosing_function: String

The function the range was taken out of.

§parameters: Vec<String>

Names read in the range before the range assigns them, that are bound in the enclosing function outside the range. Sorted, so the signature and the call site cannot disagree about argument order.

§parameter_spellings: Vec<String>

How each parameter is spelled in the new signature, positionally paired with parameters. Identical to parameters in the untyped languages; in TypeScript each entry carries the annotation copied from the name’s existing binding, because a parameter list is the one place a derived signature cannot stay silent about types.

§returns: Vec<String>

Names assigned in the range and read after it, in the same order rule.

§return_type: Option<String>

The new function’s declared return type, where the language requires one. None everywhere the return is inferred.

§returns_declared_mut: bool

Whether a call site that declares what it receives has to declare it mutable, because something after the range assigns it.

§local_declarations: Vec<String>

Names the range only assigns, whose declaration stayed behind in the enclosing function. In a language where a bare assignment does not declare, the new function has to declare them itself or its body reads a name that is not there. Empty in Python, where assignment declares.

§returns_need_declaration: bool

Whether the call site must declare the returned names rather than assign them: true when the range carried their declaration away with it. Always false where declarations do not exist (Python).

§start_byte: usize

Byte range of the statements being hoisted.

§end_byte: usize§indent: String

Indentation of the hoisted statements, so the emitter can re-indent the body and place the call at the same depth.

§insert_byte: usize

Byte offset where the new function is inserted: immediately after the enclosing function, at its own indentation.

§enclosing_indent: String

Indentation of the enclosing function’s own declaration.

§indent_unit: String

One level of indentation as this file actually writes it, measured from the enclosing function’s own body rather than assumed. A file indented with tabs or two spaces gets a new function indented the same way.

Trait Implementations§

Source§

impl Clone for ExtractionPlan

Source§

fn clone(&self) -> ExtractionPlan

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 ExtractionPlan

Source§

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

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

impl Eq for ExtractionPlan

Source§

impl PartialEq for ExtractionPlan

Source§

fn eq(&self, other: &ExtractionPlan) -> 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 ExtractionPlan

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.