{"id":13683556,"url":"https://github.com/mystor/rust-cpp","last_synced_at":"2025-05-13T19:15:10.766Z","repository":{"id":33339452,"uuid":"36984252","full_name":"mystor/rust-cpp","owner":"mystor","description":"Embed C++ directly inside your rust code!","archived":false,"fork":false,"pushed_at":"2024-11-20T07:22:17.000Z","size":393,"stargazers_count":824,"open_issues_count":20,"forks_count":46,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-04-27T20:04:14.276Z","etag":null,"topics":["c-plus-plus","ffi","macros","rust","rust-cpp"],"latest_commit_sha":null,"homepage":null,"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/mystor.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2015-06-06T15:08:26.000Z","updated_at":"2025-04-19T00:22:17.000Z","dependencies_parsed_at":"2024-05-03T07:25:34.775Z","dependency_job_id":"2abb3e97-32ce-4241-8703-e4b94490206c","html_url":"https://github.com/mystor/rust-cpp","commit_stats":{"total_commits":252,"total_committers":21,"mean_commits":12.0,"dds":0.5793650793650793,"last_synced_commit":"be16bcac33c3618212c89fe444a8ced2ecf26662"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mystor%2Frust-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mystor%2Frust-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mystor%2Frust-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mystor%2Frust-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mystor","download_url":"https://codeload.github.com/mystor/rust-cpp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254010822,"owners_count":21998999,"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":["c-plus-plus","ffi","macros","rust","rust-cpp"],"created_at":"2024-08-02T13:02:15.336Z","updated_at":"2025-05-13T19:15:10.725Z","avatar_url":"https://github.com/mystor.png","language":"Rust","readme":"# rust-cpp - Embed C++ code directly in Rust\n\n[![Documentation](https://docs.rs/cpp/badge.svg)](https://docs.rs/cpp/)\n\n## Overview\n\n`rust-cpp` is a build tool \u0026 macro which enables you to write C++ code inline in\nyour rust code.\n\n```rust\nlet name = std::ffi::CString::new(\"World\").unwrap();\nlet name_ptr = name.as_ptr();\nlet r = unsafe {\n    cpp!([name_ptr as \"const char *\"] -\u003e u32 as \"int32_t\" {\n        std::cout \u003c\u003c \"Hello, \" \u003c\u003c name_ptr \u003c\u003c std::endl;\n        return 42;\n    })\n};\nassert_eq!(r, 42)\n```\n\nThe crate also help to expose some C++ class to Rust by automatically\nimplementing trait such as Drop, Clone (if the C++ type can be copied), and others\n\n```rust\ncpp_class!{\n    #[derive(PartialEq)]\n    unsafe struct MyClass as \"std::unique_ptr\u003cMyClass\u003e\"\n}\n```\n\n## Usage\n\nFor usage information and in-depth documentation, see\nthe [`cpp` crate module level documentation](https://docs.rs/cpp).\n\n\n## Differences with the [`cxx`](https://cxx.rs) crate\n\nThis crate allows to write C++ code \"inline\" within your Rust functions, while with the [`cxx`](https://cxx.rs) crate, you have\nto write a bit of boiler plate to have calls to functions declared in a different `.cpp` file.\n\nHaving C++ code inline might be helpful when trying to call to a C++ library and that one may wish to make plenty of call to small snippets.\nIt can otherwise be fastidious to write and maintain the boiler plate for many small functions in different places. \n\nThese crate can also be used in together. The `cxx` crate offer some useful types such as `CxxString` that can also be used with this crate.\n\nThe `cxx` bridge does more type checking which can avoid some classes of errors. While this crate can only check for equal size and alignment.\n","funding_links":[],"categories":["Rust","FFI Bindings","Development tools"],"sub_categories":["FFI"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmystor%2Frust-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmystor%2Frust-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmystor%2Frust-cpp/lists"}