{"id":18466943,"url":"https://github.com/sharnoff/derive-syn-parse","last_synced_at":"2025-04-08T09:31:57.613Z","repository":{"id":41355393,"uuid":"303194917","full_name":"sharnoff/derive-syn-parse","owner":"sharnoff","description":"A #[derive] macro for syn's `Parse` trait","archived":false,"fork":false,"pushed_at":"2024-03-30T14:54:59.000Z","size":64,"stargazers_count":19,"open_issues_count":4,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-23T09:48:46.757Z","etag":null,"topics":["procedural-macro","rust","syn"],"latest_commit_sha":null,"homepage":"https://docs.rs/derive-syn-parse","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sharnoff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-11T19:17:53.000Z","updated_at":"2024-11-12T05:12:33.000Z","dependencies_parsed_at":"2024-04-05T18:30:44.244Z","dependency_job_id":null,"html_url":"https://github.com/sharnoff/derive-syn-parse","commit_stats":{"total_commits":26,"total_committers":1,"mean_commits":26.0,"dds":0.0,"last_synced_commit":"c2e40087aded296f55b55a9e03270c90d3f63ea7"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharnoff%2Fderive-syn-parse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharnoff%2Fderive-syn-parse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharnoff%2Fderive-syn-parse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharnoff%2Fderive-syn-parse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sharnoff","download_url":"https://codeload.github.com/sharnoff/derive-syn-parse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247814029,"owners_count":21000485,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["procedural-macro","rust","syn"],"created_at":"2024-11-06T09:18:08.395Z","updated_at":"2025-04-08T09:31:57.289Z","avatar_url":"https://github.com/sharnoff.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![crates.io](https://img.shields.io/crates/v/derive-syn-parse.svg)](https://crates.io/crates/derive-syn-parse)\n[![docs.rs](https://docs.rs/derive-syn-parse/badge.svg)](https://docs.rs/derive-syn-parse)\n\n# `derive-syn-parse`: A derive macro for `syn`'s `Parse` trait\n\nThis is a fairly straightforward derive macro that produces an implementation `syn::parse::Parse`\nfor the type it's applied to.\n\nA common pattern when writing custom `syn` parsers is repeating `\u003cname\u003e: input.parse()?` for\neach field in the output. This crate's `#[derive(Parse)]` handles that for you, with some helpful\nextra customization.\n\n## Usage\n\nUsing this crate is as simple as adding it to your 'Cargo.toml' and importing the derive macro:\n\n```toml\n# Cargo.toml\n\n[dependencies]\nderive-syn-parse = \"0.2.0\"\n```\n\n```rust\n// your_file.rs\nuse derive_syn_parse::Parse;\n\n#[derive(Parse)]\nstruct CustomParsable {\n    // ...\n}\n```\n\nThe derived implementation of `Parse` will always parse in the order that the fields are given.\nDetailed information about the various field attributes available is given in the\n[crate documentation](https://docs.rs/derive-syn-parse).\n\nThis crate is primarily intended for users who are already making heavy use of `syn` and wish to\nreduce the amount of boilerplate code required.\n\n## Motivation\n\nWhen writing rust code that makes heavy use of `syn`'s parsing functionality, we often end up\nwriting things like:\n```rust\nuse syn::parse::{Parse, ParseStream};\nuse syn::{Ident, Token, Type};\n\n// A simplified struct field\n//\n//     x: i32\nstruct MyField {\n    ident: Ident,\n    colon_token: Token![:],\n    ty: Type,\n}\n\nimpl Parse for MyField {\n    fn parse(input: ParseStream) -\u003e syn::Result\u003cSelf\u003e {\n        Ok(MyField {\n            ident: input.parse()?,\n            colon_token: input.parse()?,\n            ty: input.parse()?,\n        })\n    }\n}\n```\nThis is really repetitive! Ideally, we'd like to just `#[derive(Parse)]` and have it work. And\nso we can! (for the most part) Adding `#[derive(Parse)]` to the previous struct produces an\nequivalent implementation of `Parse`:\n```rust\nuse syn::{Ident, Token, Type};\nuse derive_syn_parse::Parse;\n\n#[derive(Parse)]\nstruct MyField {\n    ident: Ident,\n    colon_token: Token![:],\n    ty: Type,\n}\n```\n\nOf course, there are more complicated cases. But - even though they're complicated, many of them are\nstill covered by the various advanced features provided! For more information, see the\n[crate documentation](https://docs.rs/derive-syn-parse).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsharnoff%2Fderive-syn-parse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsharnoff%2Fderive-syn-parse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsharnoff%2Fderive-syn-parse/lists"}