Skip to content

Commit

Permalink
chore: remove dependency on syn_derive
Browse files Browse the repository at this point in the history
  • Loading branch information
kayagokalp committed Nov 5, 2024
1 parent 21c024f commit 4a8bdbf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
1 change: 0 additions & 1 deletion borsh-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ proc-macro-crate = "3"
proc-macro2 = "1"
quote = "1"
once_cell = "1.18.0"
syn_derive = "0.1.6"

[dev-dependencies]
syn = { version = "2", features = ["full", "fold", "parsing"] }
Expand Down
27 changes: 25 additions & 2 deletions borsh-derive/src/internals/attributes/field/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ use crate::internals::attributes::{
Symbol,
};
use once_cell::sync::Lazy;
use syn::{meta::ParseNestedMeta, Ident, Token, Type};
use quote::ToTokens;
use syn::{
meta::ParseNestedMeta,
parse::{Parse, ParseStream},
Ident, Token, Type,
};

use self::with_funcs::{WithFuncs, WITH_FUNCS_FIELD_PARSE_MAP};

Expand Down Expand Up @@ -52,13 +57,31 @@ pub static SCHEMA_FIELD_PARSE_MAP: Lazy<BTreeMap<Symbol, Box<ParseFn>>> = Lazy::
/**
Struct describes an entry like `order_param => override_type`, e.g. `K => <K as TraitName>::Associated`
*/
#[derive(Clone, syn_derive::Parse, syn_derive::ToTokens)]
#[derive(Clone)]
pub struct ParameterOverride {
pub order_param: Ident,
arrow_token: Token![=>],
pub override_type: Type,
}

impl Parse for ParameterOverride {
fn parse(input: ParseStream) -> Result<Self, syn::Error> {
Ok(ParameterOverride {
order_param: input.parse()?,
arrow_token: input.parse()?,
override_type: input.parse()?,
})
}
}

impl ToTokens for ParameterOverride {
fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
self.order_param.to_tokens(tokens);
self.arrow_token.to_tokens(tokens);
self.override_type.to_tokens(tokens);
}
}

#[allow(unused)]
#[derive(Default, Clone)]
pub(crate) struct Attributes {
Expand Down

0 comments on commit 4a8bdbf

Please sign in to comment.