[][src]Struct TCFSMFTTTCS::TysCountingFSMForTyTtClusterSeq

pub struct TysCountingFSMForTyTtClusterSeq<T> { /* fields omitted */ }

Methods

impl<T> TysCountingFSMForTyTtClusterSeq<T>[src]

pub fn get_count(self) -> T[src]

Returns the number of counted :ty TokenTree clusters

Examples

Basic usage:

extern crate proc_macro;
extern crate proc_macro2;
extern crate quote;
extern crate proc_macro_hack;
extern crate tys_counting_fsm_for_ty_tt_cluster_seq;
 
use quote::quote;
use tys_counting_fsm_for_ty_tt_cluster_seq::TysCountingFSMForTyTtClusterSeq;
 
// TODO: Switch out from proc_macro_hack and edit documentation when
//"error: procedural macros cannot be expanded to expressions" is resloved.
// note: see issue #54727 <https://github.com/rust-lang/rust/issues/54727> for more information
#[proc_macro_hack]
pub unsafe fn unsafe_count_tys_in_ty_ts() {
    let tys_count :usize = proc_macro2::TokenStream::from(input)
        .into_iter()
        .fold(TysCountingFSMForTyTtClusterSeq::<usize>::new(), |ty_counting_fsm, tt| unsafe {
            // proof of safety
            ty_counting_fsm.unsafe_transition(tt)
        })
        .get_count();
    let expanded_tt  = quote!{#tts_count};
    proc_macro::TokenStream::from(expanded_tt)
}
 

impl<T> TysCountingFSMForTyTtClusterSeq<T> where
    T: Default
[src]

pub fn new() -> Self[src]

Constructs a new TysCountingFSMForTyTtClusterSeq

Newly constructed TysCountingFSMForTyTtClusterSeq returns Default::default with TysCountingFSMForTyTtClusterSeq::<T>::get_count

Examples

Basic usage:

extern crate tys_counting_fsm_for_ty_tt_cluster_seq;
use tys_counting_fsm_for_ty_tt_cluster_seq::TysCountingFSMForTyTtClusterSeq;
 
let tys_counting_fsm_for_ty_tt_cluster_seq = TysCountingFSMForTyTtClusterSeq::<usize>::new();
let initial_value :usize = tys_counting_fsm_for_ty_tt_cluster_seq.get_count();
assert_eq!(0, initial_value);

impl<T> TysCountingFSMForTyTtClusterSeq<T> where
    T: AddAssign + One
[src]

pub unsafe fn unsafe_transition(self, tt: TokenTree) -> Self[src]

Returns a mutable reference to the TysCountingFSMForTyTtClusterSeq in the transitioned (modified) state. Internally, counts :ty TokenTree clusters in the given TokenTree sequence assuming it is a [:ty TokenTree sequence] and using Signs of :ty TokenTree clusters` boundaries in :ty TokenTree sequence. Guarantees to correctly maintain count of encountered :ty TokenTree clusters only for traversed paths that are prefixes of [:ty TokenTree sequence].

Arguments

Safety

tt must be on the prefix-path of a :ty TokenTree cluster sequence. For example, any prefix of [:ty TokenStream]

Examples

Basic usage:

extern crate proc_macro;
extern crate proc_macro2;
extern crate quote;
extern crate proc_macro_hack;
extern crate tys_counting_fsm_for_ty_tt_cluster_seq;
 
use quote::quote;
use tys_counting_fsm_for_ty_tt_cluster_seq::TysCountingFSMForTyTtClusterSeq;
 
// TODO: Switch out from proc_macro_hack and edit documentation when
//"error: procedural macros cannot be expanded to expressions" is resloved.
// note: see issue #54727 <https://github.com/rust-lang/rust/issues/54727> for more information
#[proc_macro_hack]
pub unsafe fn unsafe_count_tys_in_ty_ts() {
    let tys_count :usize = proc_macro2::TokenStream::from(input)
        .into_iter()
        .fold(TysCountingFSMForTyTtClusterSeq::<usize>::new(), |ty_counting_fsm, tt| unsafe {
            // proof of safety
            ty_counting_fsm.unsafe_transition(tt)
        })
        .get_count();
    let expanded_tt  = quote!{#tts_count};
    proc_macro::TokenStream::from(expanded_tt)
}
 

pub unsafe fn unsafe_into_iter_transition(self, ts: TokenStream) -> Self[src]

Returns a mutable reference to the TysCountingFSMForTyTtClusterSeq in the transitioned (modified) state. Internally, counts :ty TokenTree clusters in the given TokenStream assuming it is a :ty TokenStream and using Signs of :ty TokenTree clusters` boundaries in :ty TokenTree sequence. Guarantees to correctly maintain count of encountered :ty TokenTree clusters only for traversed paths that are prefixes of [:ty TokenTree sequence].

Arguments

Safety

ts must be a :ty TokenStream

Example

extern crate proc_macro;
extern crate proc_macro2;
extern crate quote;
extern crate proc_macro_hack;
extern crate tys_counting_fsm_for_ty_tt_cluster_seq;
 
use quote::quote;
use tys_counting_fsm_for_ty_tt_cluster_seq::TysCountingFSMForTyTtClusterSeq;
 
// TODO: Switch out from proc_macro_hack and edit documentation when
//"error: procedural macros cannot be expanded to expressions" is resloved.
// note: see issue #54727 <https://github.com/rust-lang/rust/issues/54727> for more information
#[proc_macro_hack]
pub unsafe fn unsafe_count_tys_in_ty_ts() {
    let tys_counting_fsm_for_ty_tt_cluster_seq = TysCountingFSMForTyTtClusterSeq::<usize>::new();
    let tys_count :usize = unsafe {
        tys_counting_fsm_for_ty_tt_cluster_seq.unsafe_into_iter_transition proc_macro2::TokenStream::from(input)
    }
    let tys_count :usize = proc_macro2::TokenStream::from(input)
        .into_iter()
        .fold(TysCountingFSMForTyTtClusterSeq::<usize>::new(), |ty_counting_fsm, tt| unsafe {
            // proof of safety
            ty_counting_fsm.unsafe_transition(tt)
        })
        .get_count();
    let expanded_tt  = quote!{#tts_count};
    proc_macro::TokenStream::from(expanded_tt)
}
 

Trait Implementations

impl<T: Clone> Clone for TysCountingFSMForTyTtClusterSeq<T>[src]

impl<T: Copy> Copy for TysCountingFSMForTyTtClusterSeq<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for TysCountingFSMForTyTtClusterSeq<T> where
    T: RefUnwindSafe

impl<T> Send for TysCountingFSMForTyTtClusterSeq<T> where
    T: Send

impl<T> Sync for TysCountingFSMForTyTtClusterSeq<T> where
    T: Sync

impl<T> Unpin for TysCountingFSMForTyTtClusterSeq<T> where
    T: Unpin

impl<T> UnwindSafe for TysCountingFSMForTyTtClusterSeq<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.