@@ -5,8 +5,8 @@ use syn::{
55 parse:: { Parse , ParseStream } ,
66 parse_quote,
77 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 ,
1010} ;
1111
1212pub ( crate ) fn get_is_plutus_data_instance ( input : DeriveInput ) -> Result < ItemImpl > {
@@ -56,7 +56,7 @@ enum DeriveStrategy {
5656enum DeriveStrategyError {
5757 #[ error( "Unknown strategy {0}. Should be one of Newtype, List and Constr." ) ]
5858 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 ." ) ]
6060 UnexpectedToken ,
6161 #[ error( "More than one strategies specified." ) ]
6262 MoreThanOneSpecified ,
@@ -102,10 +102,11 @@ fn try_parse_derive_strategy(attr: &Attribute) -> Option<Result<DeriveStrategy>>
102102 } ?;
103103
104104 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) )
109110 } ) ( ) ,
110111 _ => Err ( Error :: new (
111112 value. span ( ) ,
0 commit comments