1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright 2022 Oxide Computer Company
//! This is a [`serde::Deserializer`] implementation for
//! [`proc_macro2::TokenStream`]. It is intended for proc_macro builders who
//! want rich configuration in their custom attributes.
//!
//! If you'd like the consumers of your macro use it like this:
//!
//! ```ignore
//! #[my_macro {
//! settings = {
//! reticulate_splines = true,
//! normalizing_power = false,
//! },
//! disaster = "pandemic",
//! }]
//! ```
//!
//! Your macro will start like this:
//!
//! ```ignore
//! #[proc_macro_attribute]
//! pub fn my_macro(
//! attr: proc_macro::TokenStream,
//! item: proc_macro::TokenStream,
//! ) -> proc_macro::TokenStream {
//! // ...
//! # }
//! ```
//!
//! Use `serde_tokenstream` to deserialize `attr` into a structure with the
//! `Deserialize` trait (typically via a `derive` macro):
//!
//! ```
//! # use proc_macro2::TokenStream;
//! # use serde_tokenstream::from_tokenstream;
//! # use serde::Deserialize;
//! # #[derive(Deserialize)]
//! # struct Config;
//! # pub fn my_macro(
//! # attr: proc_macro2::TokenStream,
//! # item: proc_macro2::TokenStream,
//! # ) -> proc_macro2::TokenStream {
//! let config = match from_tokenstream::<Config>(&TokenStream::from(attr)) {
//! Ok(c) => c,
//! Err(err) => return err.to_compile_error().into(),
//! };
//! # item
//! # }
//! ```
//!
//! ## Nested attributes
//!
//! For attributes that are nested inside a top-level macro, use the
//! [`from_tokenstream_spanned`] function. See its help for an example.
pub use crateParseWrapper;
pub use crateTokenStreamWrapper;
pub use crateOrderedMap;
pub use cratefrom_tokenstream;
pub use cratefrom_tokenstream_spanned;
pub use crateError;
pub use crateResult;