Skip to content

Commit

Permalink
Add attribute parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-pease committed Aug 20, 2024
1 parent 3124737 commit 705d5d7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions stellar_rust_sdk_derive/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern crate proc_macro2;
use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, ItemStruct, Fields, Field};
use syn::{parse_macro_input, ItemStruct, Fields, Field, parse::Nothing};

/// The procedural attribute macro to add pagination functionality to request structs.
///
Expand All @@ -28,9 +28,12 @@ use syn::{parse_macro_input, ItemStruct, Fields, Field};
/// functionality.
///
#[proc_macro_attribute]
pub fn pagination(_attr: TokenStream, input: TokenStream) -> TokenStream {
pub fn pagination(args: TokenStream, input: TokenStream) -> TokenStream {
let mut input = parse_macro_input!(input as ItemStruct);

// No arguments should be passed, but if they are, parse them as `Nothing` to prevent misuse.
let _ = parse_macro_input!(args as Nothing);

// Create required fields to be added to the struct.
let cursor_field: Field = syn::parse_quote! {
pub cursor: Option<u32>
Expand Down

0 comments on commit 705d5d7

Please sign in to comment.