pub fn relative_path(a: &str, b: &str) -> TokenStream {
    let a: Vec<&str> = a.split("::").collect();
    let b: Vec<&str> = b.split("::").collect();

    let mut ma = &a[..a.len() - 1];
    let mut mb = &b[..b.len() - 1];
    while !ma.is_empty() && !mb.is_empty() && ma[0] == mb[0] {
        ma = &ma[1..];
        mb = &mb[1..];
    }

    let mut res = TokenStream::new();

    // for each item left in b, append a `super`
    for _ in mb {
        res.extend(quote!(super::));
    }

    // for each item in a, append it
    for ident in ma {
        let ident = Ident::new(ident, Span::call_site());
        res.extend(quote!(#ident::));
    }

    let ident = Ident::new(&a[a.len() - 1], Span::call_site());
    res.extend(quote!(#ident));

    res
}
/// Return a relative path to access a from b.
Return a relative path to access a from b.
Return a relative path to access a from b .
pub fn relative_path(a: &str, b: &str) -> TokenStream {
    let a: Vec<&str> = a.split("::").collect();
    let b: Vec<&str> = b.split("::").collect();
    let mut ma = &a[..a.len() - 1];
    let mut mb = &b[..b.len() - 1];
    while !ma.is_empty() && !mb.is_empty() && ma[0] == mb[0] {
        ma = &ma[1..];
        mb = &mb[1..];
    }
    let mut res = TokenStream::new();
    // for each item left in b, append a `super`
    for _ in mb {
        res.extend(quote!(super::));
    }
    // for each item in a, append it
    for ident in ma {
        let ident = Ident::new(ident, Span::call_site());
        res.extend(quote!(#ident::));
    }
    let ident = Ident::new(&a[a.len() - 1], Span::call_site());
    res.extend(quote!(#ident));
    res
}
pub fn relative_path ( a : & str , b : & str ) -> TokenStream { let a : Vec < & str > = a . split ( " " ) . collect ( ) ; let b : Vec < & str > = b . split ( " " ) . collect ( ) ; let mut ma = & a [ .. a . len ( ) - 1 ] ; let mut mb = & b [ .. b . len ( ) - 1 ] ; while ! ma . is_empty ( ) && ! mb . is_empty ( ) && ma [ 0 ] == mb [ 0 ] { ma = & ma [ 1 .. ] ; mb = & mb [ 1 .. ] ; } let mut res = TokenStream :: new ( ) ; // for each item left in b, append a `super` for _ in mb { res . extend ( quote ! ( super ) ) ; } // for each item in a, append it for ident in ma { let ident = Ident :: new ( ident , Span :: call_site ( ) ) ; res . extend ( quote ! ( ident ) ) ; } let ident = Ident :: new ( & a [ a . len ( ) - 1 ] , Span :: call_site ( ) ) ; res . extend ( quote ! ( ident ) ) ; res }
Return a relative path to access a from b.
Return a relative path to access a from b .
a
&str
b
&str