Skip to main content

syn_mid/
lib.rs

1// SPDX-License-Identifier: Apache-2.0 OR MIT
2
3/*!
4<!-- Note: Document from sync-markdown-to-rustdoc:start through sync-markdown-to-rustdoc:end
5     is synchronized from README.md. Any changes to that range are not preserved. -->
6<!-- tidy:sync-markdown-to-rustdoc:start -->
7
8Providing the features between "full" and "derive" of syn.
9
10This crate provides the following two unique data structures.
11
12- [`syn_mid::ItemFn`] -- A function whose body is not parsed.
13
14  ```text
15  fn process(n: usize) -> Result<()> { ... }
16  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^     ^
17  ```
18
19- [`syn_mid::Block`] -- A block whose body is not parsed.
20
21  ```text
22  { ... }
23  ^     ^
24  ```
25
26Other data structures are the same as data structures of [syn]. These are
27defined in this crate because they cannot be used in [syn] without "full"
28feature.
29
30## Usage
31
32Add this to your `Cargo.toml`:
33
34```toml
35[dependencies]
36syn-mid = "0.6"
37```
38
39[**Examples**](https://github.com/taiki-e/syn-mid/tree/HEAD/examples)
40
41## Optional features
42
43- **`clone-impls`** — Clone impls for all syntax tree types.
44
45[syn]: https://github.com/dtolnay/syn
46
47<!-- tidy:sync-markdown-to-rustdoc:end -->
48*/
49
50#![no_std]
51#![doc(test(
52    no_crate_inject,
53    attr(allow(
54        dead_code,
55        unused_variables,
56        clippy::undocumented_unsafe_blocks,
57        clippy::unused_trait_names,
58    ))
59))]
60#![forbid(unsafe_code)]
61#![warn(
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::std_instead_of_alloc,
70    clippy::std_instead_of_core,
71    // clippy::missing_inline_in_public_items,
72)]
73
74// Many of the code contained in this crate are copies from https://github.com/dtolnay/syn.
75
76extern crate alloc;
77#[cfg(doc)]
78extern crate self as syn_mid;
79extern crate std;
80
81#[macro_use]
82mod macros;
83
84mod func;
85mod pat;
86mod path;
87
88#[doc(no_inline)]
89pub use syn::ExprPath as PatPath;
90
91pub use self::{
92    func::{Block, FnArg, ItemFn, Receiver, Signature, Variadic},
93    pat::{
94        FieldPat, Pat, PatIdent, PatReference, PatRest, PatStruct, PatTuple, PatTupleStruct,
95        PatType, PatWild,
96    },
97};