-
-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expand only one file #8
Comments
Being able to get the expansion of one type would also be sufficient, if that's easier to implement (after looking at the code, I'm not sure how much control |
I added support in cargo-expand 0.4 for expanding only one module or item. Check out these examples from the Syn codebase: $ cargo expand punctuated::printing
Checking syn v0.15.24
Finished dev [unoptimized + debuginfo] target(s) in 0.17s
use super::*;
use proc_macro2::TokenStream;
use quote::{ToTokens, TokenStreamExt};
impl<T, P> ToTokens for Punctuated<T, P>
where
T: ToTokens,
P: ToTokens,
{
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.pairs())
}
}
impl<T, P> ToTokens for Pair<T, P>
where
T: ToTokens,
P: ToTokens,
{
fn to_tokens(&self, tokens: &mut TokenStream) {
match *self {
Pair::Punctuated(ref a, ref b) => {
a.to_tokens(tokens);
b.to_tokens(tokens);
}
Pair::End(ref a) => a.to_tokens(tokens),
}
}
} $ cargo expand token::FatArrow
Checking syn v0.15.24
Finished dev [unoptimized + debuginfo] target(s) in 0.11s
/// `=>`
///
/// Don't try to remember the name of this type -- use the [`Token!`]
/// macro instead.
///
/// [`Token!`]: index.html
#[rustc_copy_clone_marker]
pub struct FatArrow {
pub spans: [Span; 2],
}
#[doc(hidden)]
#[allow(non_snake_case)]
pub fn FatArrow<S: IntoSpans<[Span; 2]>>(spans: S) -> FatArrow {
FatArrow {
spans: spans.into_spans(),
}
} |
Would it be possible to use this to expand code in a test? |
@dtolnay , do you mean we can expand a specific micro? for example, I am using a micro , then I can expand with
this crate is not usefull for me , be cause it expand lots of micros, it would take hours to find the one I need. |
Currently, it displays the expansion of the entire crate. For big crates, that's not very practical. Often, you want to see the expansion of only one file.
The text was updated successfully, but these errors were encountered: