{"id":34598327,"url":"https://github.com/survived/mquote","last_synced_at":"2026-03-27T02:45:41.106Z","repository":{"id":57640865,"uuid":"194574372","full_name":"survived/mquote","owner":"survived","description":"Rust templating quasi-quoting library","archived":false,"fork":false,"pushed_at":"2019-07-15T04:46:37.000Z","size":123,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-25T23:38:28.048Z","etag":null,"topics":["proc-macro","quote","rust","syn"],"latest_commit_sha":null,"homepage":"","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/survived.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}},"created_at":"2019-07-01T00:26:03.000Z","updated_at":"2019-07-23T04:27:23.000Z","dependencies_parsed_at":"2022-09-07T03:51:29.862Z","dependency_job_id":null,"html_url":"https://github.com/survived/mquote","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/survived/mquote","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/survived%2Fmquote","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/survived%2Fmquote/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/survived%2Fmquote/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/survived%2Fmquote/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/survived","download_url":"https://codeload.github.com/survived/mquote/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/survived%2Fmquote/sbom","scorecard":{"id":860299,"data":{"date":"2025-08-11","repo":{"name":"github.com/survived/mquote","commit":"c08771d80ebcee709bba84a620fa47af4d536733"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"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":"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":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"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":"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":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","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":"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":"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":"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":"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":"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":"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":"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":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE-APACHE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE-APACHE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"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"}}]},"last_synced_at":"2025-08-24T01:04:34.411Z","repository_id":57640865,"created_at":"2025-08-24T01:04:34.411Z","updated_at":"2025-08-24T01:04:34.411Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31011923,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-27T02:33:22.146Z","status":"ssl_error","status_checked_at":"2026-03-27T02:33:21.763Z","response_time":164,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["proc-macro","quote","rust","syn"],"created_at":"2025-12-24T12:01:48.747Z","updated_at":"2026-03-27T02:45:41.097Z","avatar_url":"https://github.com/survived.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"Mquote\n======\n[![Latest Version](https://img.shields.io/crates/v/mquote.svg)](https://crates.io/crates/mquote)\n[![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/mquote/)\n\nThis is another one Rust quasi-quoting library like \n[quote][quote-lib] that gives you `mquote!` macro providing\nseveral features aimed on better readability and usability.\n\n[quote-lib]: https://crates.io/crates/quote\n\n# Motivation\nThe only interpolations supported by `quote!` macros are regular insertion `#a` (and\nyou are not able to put an expression like `my_struct.field` here) and repeating \ninsertion `#(...)*`.\n\nFor me that's not enough. If you wanna conditionally put a piece of tokens, you\nhave to associate them with some variable and then interpolate it into `quote!`\nexpression:\n```rust\nlet conditional_piece = if having_fun { \n    quote!(fn funny_method() { ... }) \n} else { \n    quote!() \n};\nquote!(\n    #conditional_piece\n    fn regular_method() { ... }\n)\n```\n\nDon't you find it could be confusing? Especially if there're a lot of such things.\nEven putting simple expression like `my_struct.field` must be handled in this way.\n\n# Introduce templating `mquote!`\nIt supports:\n- [x] [expression insertion](#expression-insertion)\n- [x] [**if/else**](#if--elif--else) condition\n- [x] [**for**](#for) iteration\n- [x] [**match**](#matching)ing \n- [x] [**extend**](#extending)ing\n\nSo you're able to rewrite above code:\n```rust\nmquote!{\n    #{if having_fun}\n        fn funny_method() { ... }\n    #{endif}\n    fn regular_method() { ... }\n}\n```\n\nThis crate is not about syntax sugar only! In fact using `mquote!` in complicated\ncases gives a bit of performance increasing since it does not create a several\n`TokenStream`s and join them together, it handles everything within single \n`TokenStream`.\n\nCrate contains `mquote!` and `mquote_spanned!`. Usage examples of the first one\nare in [following section](#more-examples). The second one allow you to set\nspan of producing tokens stream by this syntax: `mquote_spanned!(span =\u003e ...)`.\n\n# More examples\n\n## Expression insertion\nTurns given expression into tokens by using \n[`ToTokens`](https://docs.rs/quote/0.6.13/quote/trait.ToTokens.html).\n```rust\nfn put_filter(enabled: bool) -\u003e  proc_macro2::TokenStream {\n    let good_person = Person{ name: \"Oleg\", age: 20 };\n    mquote!{\n        assert!(!#{enabled} || person.name == #{good_person.name} \n            \u0026\u0026 person.age \u003e= #{good_person.age})\n    } \n}\n```\n\n## If / elif / else\n```rust\nfn define_container(amount: usize) -\u003e  proc_macro2::TokenStream {\n    mquote!{\n        #{if amount \u003e 1}\n            struct People(Vec\u003cPerson\u003e);\n        #{elif amount == 1}\n            struct Human(Person);\n        #{else}\n            struct NoneHuman;\n        #{endif}\n    }\n}\n```\n\n## For\n```rust\nfn define_person(fields: Vec\u003c(Ident, Ident)\u003e) -\u003e proc_macro2::TokenStream {\n    mquote!{\n        pub struct Person {\n            #{for (name, ty) in fields}\n                #{name}: #{ty}\n            #{endfor}\n        }\n    }\n}\n```\n\n## Matching\n```rust\nfn hardcode_it(var: Ident, value: Option\u003c\u0026str\u003e) -\u003e proc_macro2::TokenStream {\n    mquote!{\n        static #var: \u0026str = #{match value}\n            #{of Some(x) if x.len() \u003e 0}\n                #{x};\n            #{of Some(_)}\n                \"case for empty strings\";\n            #{of None}\n                \"default value\";\n        #{endmatch}\n    }\n}\n```\n\n## Extending\nSometimes you want `mquote!` to consume an iterator of `TokenTree`s\nwithout cloning. It's possible with special syntax `^{iterable}` that accepts\nany `IntoIterator\u003cItem=TokenTree\u003e`.\n\n```rust\nfn assign_by_ref(stream: TokenStream) -\u003e TokenStream {\n    let tail = stream.into_iter().drop(5); // here could be something\n                                           // more reasonable\n    mquote!{\n        let _ = ^{tail}\n    }\n}\n```\n\n## Escaping `#{}` or `^{}`\nIf you want to put either `#{abc}` or `^{abc}` as is, you should double braces:\n```rust\nfn it_works() {\n    let tokens = mquote!(#{{abc}} ^{{abc}});\n    assert_eq!(tokens.to_string(), \"# { abc } ^ { abc }\")\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsurvived%2Fmquote","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsurvived%2Fmquote","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsurvived%2Fmquote/lists"}