[][src]Struct codegen::Module

pub struct Module { /* fields omitted */ }

Defines a module.

Implementations

impl Module[src]

pub fn new(name: &str) -> Self[src]

Return a new, blank module

pub fn scope(&mut self) -> &mut Scope[src]

Returns a mutable reference to the module's scope.

pub fn vis(&mut self, vis: &str) -> &mut Self[src]

Set the module visibility.

pub fn import(&mut self, path: &str, ty: &str) -> &mut Self[src]

Import a type into the module's scope.

This results in a new use statement bein added to the beginning of the module.

pub fn new_module(&mut self, name: &str) -> &mut Module[src]

Push a new module definition, returning a mutable reference to it.

Panics

Since a module's name must uniquely identify it within the scope in which it is defined, pushing a module whose name is already defined in this scope will cause this function to panic.

In many cases, the get_or_new_module function is preferrable, as it will return the existing definition instead.

pub fn get_module<Q: ?Sized>(&self, name: &Q) -> Option<&Module> where
    String: PartialEq<Q>, 
[src]

Returns a reference to a module if it is exists in this scope.

pub fn get_module_mut<Q: ?Sized>(&mut self, name: &Q) -> Option<&mut Module> where
    String: PartialEq<Q>, 
[src]

Returns a mutable reference to a module if it is exists in this scope.

pub fn get_or_new_module(&mut self, name: &str) -> &mut Module[src]

Returns a mutable reference to a module, creating it if it does not exist.

pub fn push_module(&mut self, item: Module) -> &mut Self[src]

Push a module definition.

Panics

Since a module's name must uniquely identify it within the scope in which it is defined, pushing a module whose name is already defined in this scope will cause this function to panic.

In many cases, the get_or_new_module function is preferrable, as it will return the existing definition instead.

pub fn new_struct(&mut self, name: &str) -> &mut Struct[src]

Push a new struct definition, returning a mutable reference to it.

pub fn push_struct(&mut self, item: Struct) -> &mut Self[src]

Push a structure definition

pub fn new_fn(&mut self, name: &str) -> &mut Function[src]

Push a new function definition, returning a mutable reference to it.

pub fn push_fn(&mut self, item: Function) -> &mut Self[src]

Push a function definition

pub fn new_enum(&mut self, name: &str) -> &mut Enum[src]

Push a new enum definition, returning a mutable reference to it.

pub fn push_enum(&mut self, item: Enum) -> &mut Self[src]

Push an enum definition

pub fn new_impl(&mut self, target: &str) -> &mut Impl[src]

Push a new impl block, returning a mutable reference to it.

pub fn push_impl(&mut self, item: Impl) -> &mut Self[src]

Push an impl block.

pub fn push_trait(&mut self, item: Trait) -> &mut Self[src]

Push a trait definition

pub fn fmt(&self, fmt: &mut Formatter) -> Result[src]

Formats the module using the given formatter.

Trait Implementations

impl Clone for Module[src]

impl Debug for Module[src]

Auto Trait Implementations

impl RefUnwindSafe for Module

impl Send for Module

impl Sync for Module

impl Unpin for Module

impl UnwindSafe for Module

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.