[−][src]Struct codegen_rs::Module
Defines a module.
Fields
name: String
Module name
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 Self
[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<&Self> 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 Self> 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 Self
[src]
Returns a mutable reference to a module, creating it if it does not exist.
pub fn push_module(&mut self, item: Self) -> &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
Auto Trait Implementations
impl RefUnwindSafe for Module
[src]
impl Send for Module
[src]
impl Sync for Module
[src]
impl Unpin for Module
[src]
impl UnwindSafe for Module
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,