[−][src]Struct codegen::Scope
Defines a scope.
A scope contains modules, types, etc...
Implementations
impl Scope
[src]
pub fn new() -> Self
[src]
Returns a new scope
pub fn import(&mut self, path: &str, ty: &str) -> &mut Import
[src]
Import a type into the scope.
This results in a new use
statement being added to the beginning of
the scope.
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_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_module<Q: ?Sized>(&self, name: &Q) -> Option<&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 struct 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_trait(&mut self, name: &str) -> &mut Trait
[src]
Push a new trait definition, returning a mutable reference to it.
pub fn push_trait(&mut self, item: Trait) -> &mut Self
[src]
Push a trait definition
pub fn new_enum(&mut self, name: &str) -> &mut Enum
[src]
Push a new struct definition, returning a mutable reference to it.
pub fn push_enum(&mut self, item: Enum) -> &mut Self
[src]
Push a structure 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 raw(&mut self, val: &str) -> &mut Self
[src]
Push a raw string to the scope.
This string will be included verbatim in the formatted string.
pub fn to_string(&self) -> String
[src]
Return a string representation of the scope.
pub fn fmt(&self, fmt: &mut Formatter) -> Result
[src]
Formats the scope using the given formatter.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Scope
impl Send for Scope
impl Sync for Scope
impl Unpin for Scope
impl UnwindSafe for Scope
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,
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.
fn to_owned(&self) -> T
[src]
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.
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>,