{"id":24905776,"url":"https://github.com/as1100k/pastey","last_synced_at":"2025-04-14T08:12:55.546Z","repository":{"id":275112253,"uuid":"925091968","full_name":"AS1100K/pastey","owner":"AS1100K","description":"Macros for all your token pasting needs. Successor of paste","archived":false,"fork":false,"pushed_at":"2025-03-12T05:25:17.000Z","size":399,"stargazers_count":12,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T08:12:48.426Z","etag":null,"topics":["development-tools","no-std","paste","rust"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/pastey","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/AS1100K.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"AS1100K"}},"created_at":"2025-01-31T07:58:01.000Z","updated_at":"2025-03-25T13:49:55.000Z","dependencies_parsed_at":"2025-01-31T09:30:02.377Z","dependency_job_id":"0fef10ed-0c66-4899-9090-d287edb5ebc1","html_url":"https://github.com/AS1100K/pastey","commit_stats":null,"previous_names":["as1100k/pastey"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AS1100K%2Fpastey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AS1100K%2Fpastey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AS1100K%2Fpastey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AS1100K%2Fpastey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AS1100K","download_url":"https://codeload.github.com/AS1100K/pastey/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248843941,"owners_count":21170495,"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":["development-tools","no-std","paste","rust"],"created_at":"2025-02-02T00:24:51.449Z","updated_at":"2025-04-14T08:12:55.525Z","avatar_url":"https://github.com/AS1100K.png","language":"Rust","funding_links":["https://github.com/sponsors/AS1100K"],"categories":[],"sub_categories":[],"readme":"Macros for all your token pasting needs\n=======================================\n\n[\u003cimg alt=\"github\" src=\"https://img.shields.io/badge/github-as1100k/pastey-8da0cb?style=for-the-badge\u0026labelColor=555555\u0026logo=github\" height=\"20\"\u003e](https://github.com/as1100k/pastey)\n[\u003cimg alt=\"crates.io\" src=\"https://img.shields.io/crates/v/pastey.svg?style=for-the-badge\u0026color=fc8d62\u0026logo=rust\" height=\"20\"\u003e](https://crates.io/crates/pastey)\n[\u003cimg alt=\"docs.rs\" src=\"https://img.shields.io/badge/docs.rs-pastey-66c2a5?style=for-the-badge\u0026labelColor=555555\u0026logo=docs.rs\" height=\"20\"\u003e](https://docs.rs/pastey)\n[\u003cimg alt=\"build status\" src=\"https://img.shields.io/github/actions/workflow/status/as1100k/pastey/ci.yml?branch=master\u0026style=for-the-badge\" height=\"20\"\u003e](https://github.com/as1100k/pastey/actions?query=branch%master)\n\n**_`pastey` is the fork of `paste` and is aimed to be a drop-in replacement with additional features for\n`paste` crate_**\n\n\u003cbr/\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eMigrating from \u003ccode\u003epaste\u003c/code\u003e crate\u003c/summary\u003e\n\nMigrating from `paste` crate to `pastey` is super simple, just change the following in your `Cargo.toml`\n\n```diff\n[dependencies]\n- paste = \"1\"\n+ pastey = \"*\" # Or any specific version of pastey\n```\n\nOr even better way:\n\n```diff\n[dependencies]\n- paste = \"1\"\n+ paste = { package = \"pastey\", version = \"*\" }\n```\n\n\u003c/details\u003e\n\n\u003cbr\u003e\n\n## Quick Start\n\nAdd `pastey` as your dependency in `Cargo.toml`\n\n```toml\n[dependencies]\n# TODO: Replace with latest version available on crates.io\npastey = \"*\"\n```\n\nThis approach works with any Rust compiler 1.54+.\n\n## Pasting identifiers\n\nWithin the `paste!` macro, identifiers inside `[\u003c`...`\u003e]` are pasted together to\nform a single identifier.\n\n```rust\nuse pastey::paste;\n\npaste! {\n    // Defines a const called `QRST`.\n    const [\u003cQ R S T\u003e]: \u0026str = \"success!\";\n}\n\nfn main() {\n    assert_eq!(\n        paste! { [\u003cQ R S T\u003e].len() },\n        8,\n    );\n}\n```\n\n\u003cbr\u003e\n\n## More elaborate example\n\nThe next example shows a macro that generates accessor methods for some struct\nfields. It demonstrates how you might find it useful to bundle a paste\ninvocation inside of a macro\\_rules macro.\n\n```rust\nuse pastey::paste;\n\nmacro_rules! make_a_struct_and_getters {\n    ($name:ident { $($field:ident),* }) =\u003e {\n        // Define a struct. This expands to:\n        //\n        //     pub struct S {\n        //         a: String,\n        //         b: String,\n        //         c: String,\n        //     }\n        pub struct $name {\n            $(\n                $field: String,\n            )*\n        }\n\n        // Build an impl block with getters. This expands to:\n        //\n        //     impl S {\n        //         pub fn get_a(\u0026self) -\u003e \u0026str { \u0026self.a }\n        //         pub fn get_b(\u0026self) -\u003e \u0026str { \u0026self.b }\n        //         pub fn get_c(\u0026self) -\u003e \u0026str { \u0026self.c }\n        //     }\n        paste! {\n            impl $name {\n                $(\n                    pub fn [\u003cget_ $field\u003e](\u0026self) -\u003e \u0026str {\n                        \u0026self.$field\n                    }\n                )*\n            }\n        }\n    }\n}\n\nmake_a_struct_and_getters!(S { a, b, c });\n\nfn call_some_getters(s: \u0026S) -\u003e bool {\n    s.get_a() == s.get_b() \u0026\u0026 s.get_c().is_empty()\n}\n```\n\n\u003cbr\u003e\n\n## Case conversion\n\nThe `pastey` crate supports the following case modfiers:\n\n| Modifier                           | Description                           |\n|------------------------------------|---------------------------------------|\n| `$var:lower`                       | Lower Case                            |\n| `$var:upper`                       | Upper Case                            |\n| `$var:snake`                       | [Snake Case]                          |\n| `$var:camel` or `$var:upper_camel` | Upper Camel Case                      |\n| `$var:lower_camel`                 | Lower Camel Case [#4]                 |\n| `$var:camel_edge`                  | Covers Edge cases of Camel Case. [#3] |\n\n_**NOTE: The pastey crate is going to be a drop in replacement to paste crate,\nand will not change the behaviour of existing modifier like `lower`, `upper`,\n`snake` and `camel`. For modifying the behaviour new modifiers will be created,\nlike `camel_edge`**_\n\nYou can also use multiple of these modifers like `$var:snake:upper` would give you\n`SCREAMING_SNAKE_CASE`.\n\nExample\n\n```rust\nuse pastey::paste;\n\npaste! {\n    const [\u003cLIB env!(\"CARGO_PKG_NAME\"):snake:upper\u003e]: \u0026str = \"libpastey\";\n\n    let _ = LIBPASTEY;\n}\n```\n\nThe precise Unicode conversions are as defined by [`str::to_lowercase`] and\n[`str::to_uppercase`].\n\n[#3]: https://github.com/AS1100K/pastey/issues/3\n[#4]: https://github.com/AS1100K/pastey/issues/4\n[`str::to_lowercase`]: https://doc.rust-lang.org/std/primitive.str.html#method.to_lowercase\n[`str::to_uppercase`]: https://doc.rust-lang.org/std/primitive.str.html#method.to_uppercase\n\n\u003cbr\u003e\n\n## Raw Identifier Generation\n\n`pastey` now supports raw identifiers using a special raw mode. By prefixing a token with `#`\ninside the paste syntax, it treats that token as a raw identifier.\n\n```rust\nuse pastey::paste;\n\nmacro_rules! define_struct_and_impl {\n    ($name:ident $(- $name_tail:ident)*) =\u003e {\n        paste!{\n            struct [\u003c # $name:camel $( $name_tail)* \u003e]; // '#' signals a raw identifier\n\n            impl [\u003c # $name:camel $( $name_tail)* \u003e] {\n                fn [\u003c # $name:snake $( _ $name_tail:snake)* \u003e]() {}\n            }\n\n        }\n    }\n}\n\ndefine_struct_and_impl!(loop);\ndefine_struct_and_impl!(loop - xyz);\n\nfn test_fn() {\n    let _ = Loop::r#loop();\n    let _ = Loopxyz::loop_xyz();\n}\n```\n\n\u003cbr\u003e\n\n## Pasting documentation strings\n\nWithin the `paste!` macro, arguments to a #\\[doc ...\\] attribute are implicitly\nconcatenated together to form a coherent documentation string.\n\n```rust\nuse pastey::paste;\n\nmacro_rules! method_new {\n    ($ret:ident) =\u003e {\n        paste! {\n            #[doc = \"Create a new `\" $ret \"` object.\"]\n            pub fn new() -\u003e $ret { todo!() }\n        }\n    };\n}\n\npub struct Pastey {}\n\nmethod_new!(Pastey);  // expands to #[doc = \"Create a new `Paste` object\"]\n```\n\n\u003cbr\u003e\n\n#### Credits\n\n\u003csup\u003e\nThis crate is the fork of \u003ca href=\"https://github.com/dtolnay/paste\"\u003e\u003ccode\u003epaste\u003c/code\u003e\u003c/a\u003e and I appreciate the efforts of\n@dtolnay and other contributors.\n\u003c/sup\u003e\n\n#### License\n\n\u003csup\u003e\nLicensed under either of \u003ca href=\"LICENSE-APACHE\"\u003eApache License, Version\n2.0\u003c/a\u003e or \u003ca href=\"LICENSE-MIT\"\u003eMIT license\u003c/a\u003e at your option.\n\u003c/sup\u003e\n\n\u003cbr\u003e\n\n\u003csub\u003e\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in this crate by you, as defined in the Apache-2.0 license, shall\nbe dual licensed as above, without any additional terms or conditions.\n\u003c/sub\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fas1100k%2Fpastey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fas1100k%2Fpastey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fas1100k%2Fpastey/lists"}