{"id":19274393,"url":"https://github.com/regexident/apply_attr","last_synced_at":"2025-09-29T03:31:25.712Z","repository":{"id":57491584,"uuid":"59021061","full_name":"regexident/apply_attr","owner":"regexident","description":"A syntax extension providing higher-order attributes to Rust.","archived":false,"fork":false,"pushed_at":"2017-12-03T16:38:51.000Z","size":960,"stargazers_count":17,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-23T01:25:10.269Z","etag":null,"topics":["compiler-plugin","metaprogramming","rust"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/regexident.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-17T12:39:49.000Z","updated_at":"2025-02-19T21:24:05.000Z","dependencies_parsed_at":"2022-08-30T23:22:07.488Z","dependency_job_id":null,"html_url":"https://github.com/regexident/apply_attr","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/regexident/apply_attr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/regexident%2Fapply_attr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/regexident%2Fapply_attr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/regexident%2Fapply_attr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/regexident%2Fapply_attr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/regexident","download_url":"https://codeload.github.com/regexident/apply_attr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/regexident%2Fapply_attr/sbom","scorecard":{"id":768843,"data":{"date":"2025-08-11","repo":{"name":"github.com/regexident/apply_attr","commit":"dcd639443c8cff41d2ec0d10dfaa88113c5414bb"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":1,"reason":"Found 1/7 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Info: FSF or OSI recognized license: Mozilla Public License 2.0: LICENSE.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 1 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T01:39:50.806Z","repository_id":57491584,"created_at":"2025-08-23T01:39:50.806Z","updated_at":"2025-08-23T01:39:50.806Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277422628,"owners_count":25815346,"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","status":"online","status_checked_at":"2025-09-28T02:00:08.834Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["compiler-plugin","metaprogramming","rust"],"created_at":"2024-11-09T20:46:04.003Z","updated_at":"2025-09-29T03:31:25.461Z","avatar_url":"https://github.com/regexident.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# apply_attr\n\n[![Build Status](http://img.shields.io/travis/regexident/apply_attr.svg?style=flat-square)](https://travis-ci.org/regexident/apply_attr)\n[![Downloads](https://img.shields.io/crates/d/apply_attr.svg?style=flat-square)](https://crates.io/crates/apply_attr/)\n[![Version](https://img.shields.io/crates/v/apply_attr.svg?style=flat-square)](https://crates.io/crates/apply_attr/)\n[![License](https://img.shields.io/crates/l/apply_attr.svg?style=flat-square)](https://crates.io/crates/apply_attr/)\n\n## Synopsis\n\nA syntax extension providing higher-order attributes to Rust.\n\n## Motivation\n\nSometimes it would be desirable to be able to apply certain attributes to all items in a scope (`mod`, `trait` or `impl`). The **`apply_attr`** crate aims to provide a versatile API for this.\n\nPossible use-cases would be:\n\n- Make all structs in mod `xyz` use `#[derive(PartialEq)]`.\n- Mark all methods in a certain `impl` with `#[inline(never)]` (for profiling, e.g.).\n- …\n\n## Getting Started\n\nAdd the most recent [version](https://crates.io/crates/apply_attr) of `apply_attr`\nto your dependencies in your project's `Cargo.toml`.\n\nThen add …\n\n```rust\n#![feature(custom_attribute)]\n\n#![feature(plugin)]\n#![plugin(apply_attr)]\n```\n\n… to your crate's root file (e.g. `lib.rs`, `main.rs`).\n\nOnce that's done you're ready to play!\n\n# Example\n\n```rust\n#![feature(custom_attribute)]\n\n#![feature(plugin)]\n#![plugin(apply_attr)]\n\n// Make all top-level structs as well as those\n// within top-level mods implement `PartialEq`:\n#![apply_attr(to(structs, mods(structs)), as_default(derive(PartialEq)))]\n\npub struct Foo;\n\nmod Bar {\n  pub struct Baz;\n  // ...\n}\n\n// Disable inlining when `no_inline` feature is present:\n#[cfg_attr(feature = \"no_inline\", apply_attr(to(fns), as_override(inline(never))))]\nimpl Blee {\n  fn foo(\u0026self) { ... }\n  fn bar(\u0026self) { ... }\n  fn baz(\u0026self) { ... }\n  fn blee(\u0026self) { ... }\n}\n\nfn main() {\n  Foo == Foo;\n  Bar::Baz == Bar::Baz;\n}\n```\n\n## API Reference\n\nThe `apply_attr` syntax extension provides a single higher-order attribute,\nconveniently named `apply_attr` expecting two arguments:\n\n1. `to(...)` (with `...` being a list of zero or more selectors).\n2. `as_default(...)` or `as_override(...)` (with `...` being a list of zero or more attributes).\n\nResulting either of:\n\n```rust\n#[apply_attr(to(...), as_default(...))]\n#[apply_attr(to(...), as_override(...))]\n```\n\nThe first argument (`to(...)`) accepts a nested list of item selectors.\n\n## Selectors\n\nSelectors behave similar to CSS selectors:\n\nAs such a CSS selector like `div \u003e span, p` would translate to `to(div(span), p)`.\n\n### Flat Selectors\n\nThe following selectors are supported:\n\n```rust\nconsts\ncrates\ndef_impls\nenums\nfgn_mods\nfns\nimpls\nmacros\nmods\nstatics\nstructs\ntraits\ntypes\nuses\n```\n\n### Nested Selectors\n\nWith the following ones allowing for nesting:\n\n```rust\nmods(...)\nimpls(...)\ntraits(...)\n```\n\nNested selectors denote direct ancestry equivalent to CSS's `outer \u003e inner` path operator.\n\n## Attributes\n\n### Default\n\nAttributes can either be applied as using `as_default(...)`, in which case …\n\n```rust\n#[apply_attr(to(fns), as_default(inline(never)))]\nimpl Foo {\n  #[inline(always)]\n  fn foo() { ... }\n}\n```\n\n… will be turned into …\n\n```rust\nimpl Foo {\n  #[inline(always)]\n  fn foo() { ... }\n}\n```\n\n… upon completion.\n\n### Overriding\n\nOr using `as_override(...)`, in which case …\n\n```rust\n#[apply_attr(to(fns), as_override(inline(never)))]\nimpl Foo {\n  #[inline(always)]\n  fn foo() { ... }\n}\n```\n\n… will be turned into …\n\n```rust\nimpl Foo {\n  #[inline(never)]\n  fn foo() { ... }\n}\n```\n\n… upon completion.\n\n## Debugging\n\nTo see how the attributes were applied compile your crate using this (requires `nightly`):\n\n```bash\ncargo rustc -- -Z unstable-options --pretty=expanded\n```\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our [code of conduct](https://www.rust-lang.org/conduct.html),\nand the process for submitting pull requests to us.\n\n## Versioning\n\nWe use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/regexident/apply_attr/tags).\n\n## Authors\n\n* **Vincent Esche** – *Initial work* – [Regexident](https://github.com/Regexident)\n\nSee also the list of [contributors](https://github.com/regexident/apply_attr/contributors) who participated in this project.\n\n## License\n\nThis project is licensed under the [**MPL-2.0**](https://www.tldrlegal.com/l/mpl-2.0) – see the [LICENSE.md](LICENSE.md) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fregexident%2Fapply_attr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fregexident%2Fapply_attr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fregexident%2Fapply_attr/lists"}