syn_mid/
lib.rs

1// SPDX-License-Identifier: Apache-2.0 OR MIT
2
3/*!
4<!-- tidy:crate-doc:start -->
5Providing the features between "full" and "derive" of syn.
6
7This crate provides the following two unique data structures.
8
9- [`syn_mid::ItemFn`] -- A function whose body is not parsed.
10
11  ```text
12  fn process(n: usize) -> Result<()> { ... }
13  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^     ^
14  ```
15
16- [`syn_mid::Block`] -- A block whose body is not parsed.
17
18  ```text
19  { ... }
20  ^     ^
21  ```
22
23Other data structures are the same as data structures of [syn]. These are
24defined in this crate because they cannot be used in [syn] without "full"
25feature.
26
27## Usage
28
29Add this to your `Cargo.toml`:
30
31```toml
32[dependencies]
33syn-mid = "0.5"
34```
35
36*Compiler support: requires rustc 1.56+*
37
38[**Examples**](https://github.com/taiki-e/syn-mid/tree/HEAD/examples)
39
40## Optional features
41
42- **`clone-impls`** — Clone impls for all syntax tree types.
43
44[syn]: https://github.com/dtolnay/syn
45
46<!-- tidy:crate-doc:end -->
47*/
48
49#![doc(test(
50    no_crate_inject,
51    attr(
52        deny(warnings, rust_2018_idioms, single_use_lifetimes),
53        allow(dead_code, unused_variables)
54    )
55))]
56#![forbid(unsafe_code)]
57#![warn(
58    rust_2018_idioms,
59    single_use_lifetimes,
60    unreachable_pub,
61    clippy::pedantic,
62    // Lints that may help when writing public library.
63    // missing_debug_implementations,
64    // missing_docs,
65    clippy::alloc_instead_of_core,
66    // clippy::exhaustive_enums, // TODO
67    // clippy::exhaustive_structs, // TODO
68    clippy::impl_trait_in_params,
69    // clippy::missing_inline_in_public_items,
70    // clippy::std_instead_of_alloc,
71    clippy::std_instead_of_core,
72)]
73#![allow(clippy::missing_errors_doc, clippy::module_name_repetitions)]
74
75// Many of the code contained in this crate are copies from https://github.com/dtolnay/syn.
76
77#[cfg(doc)]
78extern crate self as syn_mid;
79
80#[macro_use]
81mod macros;
82
83mod func;
84mod pat;
85mod path;
86
87#[doc(no_inline)]
88pub use syn::ExprPath as PatPath;
89
90pub use crate::{
91    func::{Block, FnArg, ItemFn, Receiver, Signature, Variadic},
92    pat::{
93        FieldPat, Pat, PatIdent, PatReference, PatRest, PatStruct, PatTuple, PatTupleStruct,
94        PatType, PatWild,
95    },
96};