Skip to main content

ElmModule

Struct ElmModule 

Source
pub struct ElmModule {
    pub header: Spanned<ModuleHeader>,
    pub module_documentation: Option<Spanned<String>>,
    pub imports: Vec<Spanned<Import>>,
    pub declarations: Vec<Spanned<Declaration>>,
    pub comments: Vec<Spanned<Comment>>,
}
Expand description

The root AST node representing a complete Elm source file.

Corresponds to:

  • Module in AST/Source.hs
  • File in Elm.Syntax.File

Fields§

§header: Spanned<ModuleHeader>

The module header declaration.

§module_documentation: Option<Spanned<String>>

Module-level documentation comment (appears after the header, before imports).

In Elm, a {-| ... -} comment immediately after the module ... exposing (...) header is the module’s documentation. It is distinct from comments attached to individual declarations.

§imports: Vec<Spanned<Import>>

Import declarations, in source order.

§declarations: Vec<Spanned<Declaration>>

Top-level declarations, in source order.

§comments: Vec<Spanned<Comment>>

Comments that are not attached to any declaration.

These are collected separately to allow round-trip fidelity when printing the AST back to source.

Implementations§

Source§

impl ElmModule

Source

pub fn leading_comments(&self, decl_index: usize) -> Vec<&Spanned<Comment>>

Get comments that appear immediately before a declaration.

A comment is considered “leading” if it appears between the end of the previous declaration (or the last import, or the module header) and the start of this declaration.

Note: only comments that were captured during parsing are available. For complete comment extraction, use extract_comments on the original token stream.

Source

pub fn trailing_comment(&self, decl_index: usize) -> Option<&Spanned<Comment>>

Get comments that appear on the same line as the end of a declaration (trailing line comments).

Source

pub fn module_comments(&self) -> Vec<&Spanned<Comment>>

Get all comments that appear before any declarations (module-level header comments, after imports).

Trait Implementations§

Source§

impl Clone for ElmModule

Source§

fn clone(&self) -> ElmModule

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 ElmModule

Source§

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

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

impl Display for ElmModule

Source§

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

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

impl PartialEq for ElmModule

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for ElmModule

Source§

impl StructuralPartialEq for ElmModule

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.