[−][src]Struct genco::prelude::rust::Type
An imported name in Rust.
Implementations
impl Type
[src]
pub fn alias<A: Into<ItemStr>>(self, alias: A) -> Self
[src]
Alias the given type as it's imported.
Examples
use genco::prelude::*; let ty = rust::imported("std::fmt", "Debug").alias("FmtDebug"); let toks = quote!(#ty); assert_eq!( vec![ "use std::fmt::Debug as FmtDebug;", "", "FmtDebug", ], toks.to_file_vec()? );
pub fn module_alias<A: Into<ItemStr>>(self, alias: A) -> Type
[src]
Alias the module being imported.
This also implies that the import is prefixed.
Examples
use genco::prelude::*; let ty = rust::imported("std::fmt", "Debug").module_alias("other"); let toks = quote!(#ty); assert_eq!( vec![ "use std::fmt as other;", "", "other::Debug", ], toks.to_file_vec()? );
pub fn prefixed(self) -> Type
[src]
Prefix any use of this type with the corresponding module.
So importing std::fmt::Debug
will cause the module to be referenced as
fmt::Debug
instead of Debug
.
This is implied if module_alias() is used.
Examples
use genco::prelude::*; let ty = rust::imported("std::fmt", "Debug").prefixed(); let toks = quote!(#ty); assert_eq!( vec![ "use std::fmt;", "", "fmt::Debug", ], toks.to_file_vec()? );
pub fn with_arguments(self, args: impl Args) -> Type
[src]
Add generic arguments to the type.
Examples
use genco::prelude::*; let ty = rust::imported("std::collections", "HashMap") .with_arguments((rust::local("u32"), rust::local("u32"))); let toks = quote!(#ty); assert_eq!( vec![ "use std::collections::HashMap;", "", "HashMap<u32, u32>", ], toks.to_file_vec()? );
use genco::prelude::*; let dbg = rust::imported("std::collections", "HashMap") .prefixed() .with_arguments((rust::local("T"), rust::local("U"))); let toks = quote!(#dbg); assert_eq!( vec![ "use std::collections;", "", "collections::HashMap<T, U>", ], toks.to_file_vec()? );
pub fn reference<R: Into<Reference>>(self, reference: R) -> Self
[src]
Convert into a reference &<type>
type.
pub fn into_dyn(self) -> Self
[src]
Convert into a dynamic dyn <type>
type.
Trait Implementations
impl Clone for Type
[src]
impl Debug for Type
[src]
impl Eq for Type
[src]
impl FormatTokens<Rust> for Type
[src]
fn format_tokens(self, tokens: &mut Tokens<Rust>)
[src]
fn into_tokens(self) -> Tokens<L> where
Self: Sized,
[src]
Self: Sized,
impl<'a> FormatTokens<Rust> for &'a Type
[src]
fn format_tokens(self, tokens: &mut Tokens<Rust>)
[src]
fn into_tokens(self) -> Tokens<L> where
Self: Sized,
[src]
Self: Sized,
impl<'a> From<&'a Type> for LangBox<Rust>
[src]
impl From<Type> for LangBox<Rust>
[src]
impl Hash for Type
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl LangItem<Rust> for Type
[src]
fn format(
&self,
out: &mut Formatter,
config: &Config,
format: &Format
) -> Result
[src]
&self,
out: &mut Formatter,
config: &Config,
format: &Format
) -> Result
fn as_import(&self) -> Option<&Self>
[src]
fn eq(&self, other: &dyn LangItem<Rust>) -> bool
[src]
fn as_any(&self) -> &dyn Any
[src]
impl Ord for Type
[src]
fn cmp(&self, other: &Type) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<Type> for Type
[src]
impl PartialOrd<Type> for Type
[src]
fn partial_cmp(&self, other: &Type) -> Option<Ordering>
[src]
fn lt(&self, other: &Type) -> bool
[src]
fn le(&self, other: &Type) -> bool
[src]
fn gt(&self, other: &Type) -> bool
[src]
fn ge(&self, other: &Type) -> bool
[src]
impl StructuralEq for Type
[src]
impl StructuralPartialEq for Type
[src]
Auto Trait Implementations
impl RefUnwindSafe for Type
impl Send for Type
impl Sync for Type
impl Unpin for Type
impl UnwindSafe for Type
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>,