[−][src]Struct codegen::Module
Defines a module.
Methods
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]
String: PartialEq<Q>,
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]
String: PartialEq<Q>,
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_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 fmt(&self, fmt: &mut Formatter) -> Result
[src]
Formats the module using the given formatter.
Trait Implementations
impl Clone for Module
[src]
fn clone(&self) -> Module
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Module
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,