{"id":18019492,"url":"https://github.com/timvermeulen/const-buffer","last_synced_at":"2025-03-26T20:31:22.381Z","repository":{"id":57610598,"uuid":"238080756","full_name":"timvermeulen/const-buffer","owner":"timvermeulen","description":"A fixed-capacity memory buffer allocated on the stack using const generics.","archived":false,"fork":false,"pushed_at":"2020-10-06T21:26:25.000Z","size":18,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-30T07:06:44.393Z","etag":null,"topics":["array","const-generics","data-structures","no-std","rust"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/const-buffer","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/timvermeulen.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":"2020-02-03T23:09:49.000Z","updated_at":"2021-10-21T18:58:25.000Z","dependencies_parsed_at":"2022-09-03T10:01:55.006Z","dependency_job_id":null,"html_url":"https://github.com/timvermeulen/const-buffer","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timvermeulen%2Fconst-buffer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timvermeulen%2Fconst-buffer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timvermeulen%2Fconst-buffer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timvermeulen%2Fconst-buffer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timvermeulen","download_url":"https://codeload.github.com/timvermeulen/const-buffer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245731408,"owners_count":20663177,"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":["array","const-generics","data-structures","no-std","rust"],"created_at":"2024-10-30T05:10:51.902Z","updated_at":"2025-03-26T20:31:22.062Z","avatar_url":"https://github.com/timvermeulen.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# const-buffer\n\n[![crates.io](https://img.shields.io/crates/v/const-buffer)](https://crates.io/crates/const-buffer)\n[![docs.rs](https://docs.rs/const-buffer/badge.svg)](https://docs.rs/const-buffer)\n![rustc version](https://img.shields.io/badge/rustc-nightly-inactive)\n\nA fixed-capacity memory buffer allocated on the stack using const generics.\n\nThis is a low-level utility, useful for implementing higher-level data structures such as fixed-capacity vectors and ring buffers. Since `ConstBuffer`'s main purpose is to build safe abstractions on top of, almost its entire API surface is `unsafe`.\n\n`ConstBuffer` does not keep track of which elements are in an initialized state. Furthermore, in order to ensure optimal performance, **no bounds checks are performed** unless debug assertions are enabled. Any misuse of this crate leads to undefined behavior.\n\n## Example usage\n\n```rust\nuse const_buffer::ConstBuffer;\n\nfn main() {\n    let mut buffer = ConstBuffer::\u003cu32, 10\u003e::new();\n\n    unsafe {\n        buffer.copy_from_slice(2, \u0026[10, 20, 30]);\n        // [_, _, 10, 20, 30, _, _, _, _, _]\n        buffer.write(5, 40);\n        // [_, _, 10, 20, 30, 40, _, _, _, _]\n        assert_eq!(buffer.get(3), \u002620);\n        assert_eq!(buffer.get(2..6), \u0026[10, 20, 30, 40]);\n\n        buffer.copy_within(2..6, 0);\n        // [10, 20, 30, 40, 30, 40, _, _, _, _]\n        buffer.get_mut(1..4).reverse();\n        // [10, 40, 30, 20, 30, 40, _, _, _, _]\n        assert_eq!(buffer.get(..6), \u0026[10, 40, 30, 20, 30, 40]);\n\n        buffer.swap(3, 8);\n        // [10, 40, 30, _, 30, 40, _, _, 20, _]\n        assert_eq!(buffer.read(8), 20);\n    }\n}\n```\n\n## License\n\nLicensed under either of [Apache License, Version 2.0](LICENSE-APACHE) or [MIT License](LICENSE-MIT) at your option. Any source contributions will be dual-licensed in the same way.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimvermeulen%2Fconst-buffer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimvermeulen%2Fconst-buffer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimvermeulen%2Fconst-buffer/lists"}