pub struct Referrer { /* private fields */ }Expand description
Holds the list of types that need to be encoded, produced by Leaker::finish().
The Referrer provides methods to iterate over leak types and to expand/transform
types using a custom mapping function.
Implementations§
Source§impl Referrer
impl Referrer
Sourcepub fn iter(&self) -> impl Iterator<Item = &Type>
pub fn iter(&self) -> impl Iterator<Item = &Type>
Returns an iterator over the types that need to be encoded.
let args = encode_generics_params_to_ty(&generics.params);
referrer.iter().enumerate().map(|(ix, ty)| quote!{
impl #crate::TypeRef<#ix, #args> for #marker_ty {
type Type = #ty;
}
}).collect::<TokenStream>();Sourcepub fn into_visitor<F: FnMut(Type, usize) -> Type>(
self,
type_fn: F,
) -> Visitor<F>
pub fn into_visitor<F: FnMut(Type, usize) -> Type>( self, type_fn: F, ) -> Visitor<F>
Converts this Referrer into a Visitor that can be used to transform AST nodes.
The type_fn callback is called for each type that needs to be converted,
receiving the original type and its index, and returning the replacement type.
See Referrer::expand() for details.
Sourcepub fn expand(&self, ty: Type, type_fn: impl FnMut(Type, usize) -> Type) -> Type
pub fn expand(&self, ty: Type, type_fn: impl FnMut(Type, usize) -> Type) -> Type
Expands a type by replacing any interned types using the provided mapping function.
The type_fn callback is called for each subtype that needs to be converted,
receiving the original type and its index, and returning the replacement type.
let args = encode_generics_params_to_ty(&generics.params);
referrer.expand(ty, |_, ix| {
parse_quote!(<#marker_ty as #crate::TypeRef<#ix, #args>>::Type)
})Trait Implementations§
Source§impl ToTokens for Referrer
impl ToTokens for Referrer
Source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
Source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
Source§fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
impl Eq for Referrer
impl StructuralPartialEq for Referrer
Auto Trait Implementations§
impl Freeze for Referrer
impl RefUnwindSafe for Referrer
impl !Send for Referrer
impl !Sync for Referrer
impl Unpin for Referrer
impl UnwindSafe for Referrer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Spanned for Twhere
T: Spanned + ?Sized,
impl<T> Spanned for Twhere
T: Spanned + ?Sized,
Source§fn span(&self) -> Span
fn span(&self) -> Span
Span covering the complete contents of this syntax tree
node, or Span::call_site() if this node is empty.