@@ -5,8 +5,8 @@ use syn::{
5
5
parse:: { Parse , ParseStream } ,
6
6
parse_quote,
7
7
spanned:: Spanned ,
8
- Arm , Attribute , Block , Data , DataEnum , DataStruct , DeriveInput , Error , Expr , Fields ,
9
- FieldsNamed , FieldsUnnamed , Ident , Index , ItemImpl , Meta , Path , Result , Stmt ,
8
+ Arm , Attribute , Block , Data , DataEnum , DataStruct , DeriveInput , Error , Expr , ExprLit , Fields ,
9
+ FieldsNamed , FieldsUnnamed , Ident , Index , ItemImpl , Lit , Meta , Path , Result , Stmt ,
10
10
} ;
11
11
12
12
pub ( crate ) fn get_is_plutus_data_instance ( input : DeriveInput ) -> Result < ItemImpl > {
@@ -56,7 +56,7 @@ enum DeriveStrategy {
56
56
enum DeriveStrategyError {
57
57
#[ error( "Unknown strategy {0}. Should be one of Newtype, List and Constr." ) ]
58
58
UnknownStrategy ( String ) ,
59
- #[ error( "Unable to parse strategy. Should be an Ident ." ) ]
59
+ #[ error( "Unable to parse strategy. Should be a string literal Newtype, Constr or List ." ) ]
60
60
UnexpectedToken ,
61
61
#[ error( "More than one strategies specified." ) ]
62
62
MoreThanOneSpecified ,
@@ -102,10 +102,11 @@ fn try_parse_derive_strategy(attr: &Attribute) -> Option<Result<DeriveStrategy>>
102
102
} ?;
103
103
104
104
Some ( match & value {
105
- Expr :: Path ( path) => ( || -> Result < DeriveStrategy > {
106
- let ident = path. path . require_ident ( ) ?;
107
- DeriveStrategy :: from_str ( & ident. to_string ( ) )
108
- . map_err ( |err| Error :: new ( ident. span ( ) , err) )
105
+ Expr :: Lit ( ExprLit {
106
+ lit : Lit :: Str ( str_lit) ,
107
+ ..
108
+ } ) => ( || -> Result < DeriveStrategy > {
109
+ DeriveStrategy :: from_str ( & str_lit. value ( ) ) . map_err ( |err| Error :: new ( attr. span ( ) , err) )
109
110
} ) ( ) ,
110
111
_ => Err ( Error :: new (
111
112
value. span ( ) ,
0 commit comments