0

I am trying to use syn::parse_file function from syn crate.

But, I unable to use it and found a function in the crate with feature attribute:

#[cfg(all(feature = "parsing", feature = "full"))] 
#[cfg_attr(doc_cfg, doc(cfg(all(feature = "parsing", feature = "full"))))]
pub fn parse_file(mut content: &str) -> Result<File> {
    // other code
}

Unable to find any discription of this feature.
How do I enable these features in my project?
And use this function.

1 Answers1

1

You can enable a certain crate feature in the Cargo.toml file - where you specify the crate itself and its version.

For the syn crate, the parsing feature is enabled by default but full is not, as described in the docs.

Here you can read more about how to enable features for your crates (dependencies).

Alex Koz.
  • 490
  • 8
  • 26
at54321
  • 8,726
  • 26
  • 46
  • Cargo.toml is not a config file, it's a package manifest. In general, it's all configs, but to avoid misunderstandings, you should use this term. – Alex Koz. Aug 29 '23 at 18:06