| 1 | use syn::DeriveInput; |
|---|---|
| 2 | |
| 3 | use crate::Result; |
| 4 | |
| 5 | /// Creates an instance by parsing an entire proc-macro `derive` input, |
| 6 | /// including the, identity, generics, and visibility of the type. |
| 7 | /// |
| 8 | /// This trait should either be derived or manually implemented by a type |
| 9 | /// in the proc macro crate which is directly using `darling`. It is unlikely |
| 10 | /// that these implementations will be reusable across crates. |
| 11 | pub trait FromDeriveInput: Sized { |
| 12 | /// Create an instance from `syn::DeriveInput`, or return an error. |
| 13 | fn from_derive_input(input: &DeriveInput) -> Result<Self>; |
| 14 | } |
| 15 | |
| 16 | impl FromDeriveInput for () { |
| 17 | fn from_derive_input(_: &DeriveInput) -> Result<Self> { |
| 18 | Ok(()) |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | impl FromDeriveInput for DeriveInput { |
| 23 | fn from_derive_input(input: &DeriveInput) -> Result<Self> { |
| 24 | Ok(input.clone()) |
| 25 | } |
| 26 | } |
| 27 |
