darling_core/
from_generics.rs

1use syn::Generics;
2
3use crate::Result;
4
5/// Creates an instance by parsing an entire generics declaration, including the
6/// `where` clause.
7pub trait FromGenerics: Sized {
8    fn from_generics(generics: &Generics) -> Result<Self>;
9}
10
11impl FromGenerics for () {
12    fn from_generics(_generics: &Generics) -> Result<Self> {
13        Ok(())
14    }
15}
16
17impl FromGenerics for Generics {
18    fn from_generics(generics: &Generics) -> Result<Self> {
19        Ok(generics.clone())
20    }
21}
22
23impl<T: FromGenerics> FromGenerics for Result<T> {
24    fn from_generics(generics: &Generics) -> Result<Self> {
25        Ok(FromGenerics::from_generics(generics))
26    }
27}