{"id":33926089,"url":"https://github.com/daddinuz/cap_vec","last_synced_at":"2025-12-12T10:05:06.821Z","repository":{"id":320909690,"uuid":"1083724875","full_name":"daddinuz/cap_vec","owner":"daddinuz","description":"A heap-allocated, fixed-capacity, variable-size array, `no_std` compatible.","archived":false,"fork":false,"pushed_at":"2025-11-02T21:45:31.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-02T23:20:18.666Z","etag":null,"topics":["array","collections","heap","list","no-std","no-std-alloc","rust","vec"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/cap_vec","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daddinuz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-26T15:46:50.000Z","updated_at":"2025-11-02T21:44:38.000Z","dependencies_parsed_at":"2025-10-26T18:29:12.753Z","dependency_job_id":null,"html_url":"https://github.com/daddinuz/cap_vec","commit_stats":null,"previous_names":["daddinuz/cap_vec"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/daddinuz/cap_vec","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daddinuz%2Fcap_vec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daddinuz%2Fcap_vec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daddinuz%2Fcap_vec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daddinuz%2Fcap_vec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daddinuz","download_url":"https://codeload.github.com/daddinuz/cap_vec/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daddinuz%2Fcap_vec/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27680582,"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-12-12T02:00:06.775Z","response_time":129,"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":["array","collections","heap","list","no-std","no-std-alloc","rust","vec"],"created_at":"2025-12-12T10:04:12.470Z","updated_at":"2025-12-12T10:05:06.814Z","avatar_url":"https://github.com/daddinuz.png","language":"Rust","readme":"# cap_vec\n\n[![Crates.io](https://img.shields.io/crates/v/cap_vec.svg)](https://crates.io/crates/cap_vec)\n[![Docs.rs](https://img.shields.io/docsrs/cap_vec)](https://docs.rs/cap_vec)\n[![License](https://img.shields.io/crates/l/cap_vec.svg)](https://github.com/daddinuz/cap_vec/blob/main/LICENSE)\n\nA **heap-allocated**, **fixed-capacity**, **variable-size** array, `no_std` compatible.\n\n`CapVec\u003cT, N\u003e` provides a middle ground between stack-allocated arrays `[T; N]` and dynamically growing vectors `Vec\u003cT\u003e`.\nIt allocates a **heap-backed buffer of fixed capacity `N`**, but allows the logical length to grow or shrink dynamically, up to that capacity.\n\n---\n\n## ✨ Features\n\n- ✅ **Fixed capacity** — set at compile time.\n- ✅ **Heap allocation** — no stack overflow even for large `N`.\n- ✅ **no_std compatible** — uses only `alloc`.\n- ✅ Supports most common collection operations:\n  - `push`, `pop`, `insert`, `remove`\n  - `clear`, `extend`, `drain`\n  - `iter`, `iter_mut`, and `into_iter`\n- ✅ Safe, ergonomic API — mirrors `Vec\u003cT\u003e` where possible.\n- ✅ Zero-cost iteration (implements `Iterator`, `DoubleEndedIterator`, `FusedIterator`).\n- ✅ No hidden allocations after initialization.\n\n---\n\n## 🚀 Example\n\n```rust\nuse cap_vec::CapVec;\n\nfn main() {\n    // Create a CapVec with capacity for 4 elements\n    let mut cv = CapVec::\u003ci32, 4\u003e::new();\n\n    // Push values\n    cv.push(10).unwrap();\n    cv.push(20).unwrap();\n    cv.push(30).unwrap();\n\n    assert_eq!(cv.len(), 3);\n    assert_eq!(cv.capacity(), 4);\n    assert_eq!(cv.as_slice(), \u0026[10, 20, 30]);\n\n    // Insert in the middle\n    cv.insert(1, 15).unwrap();\n    assert_eq!(cv.as_slice(), \u0026[10, 15, 20, 30]);\n\n    // Remove one element\n    let removed = cv.remove(2);\n    assert_eq!(removed, Some(20));\n    assert_eq!(cv.as_slice(), \u0026[10, 15, 30]);\n\n    // Iterate immutably\n    for x in cv.iter() {\n        println!(\"{x}\");\n    }\n\n    // Iterate mutably\n    for x in cv.iter_mut() {\n        *x *= 2;\n    }\n\n    assert_eq!(cv.as_slice(), \u0026[20, 30, 60]);\n\n    // Consume into an iterator\n    let v: Vec\u003c_\u003e = cv.into_iter().collect();\n    assert_eq!(v, vec![20, 30, 60]);\n}\n```\n\n---\n\n## 🔨 Installation\n\nAdd `cap_vec` to your `Cargo.toml`:\n\n```bash\ncargo add cap_vec\n```\n\nor edit your Cargo.toml manually by adding:\n\n```toml\n[dependencies]\ncap_vec = \"0.2\"\n```\n\n## Safety and Coverage\n\nThis crate contains a small portion of unsafe code.  \nAll tests run under [miri](https://github.com/rust-lang/miri) and the tests cover about 80% of the code.  \nYou can generate the coverage report using [tarpaulin](https://github.com/xd009642/tarpaulin).\n\n## Contributions\n\nContributions are always welcome! Feel free to open an issue or submit a pull request.\n\n## License\n\nThis crate is licensed under the MIT License. See [LICENSE](LICENSE) for more details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaddinuz%2Fcap_vec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaddinuz%2Fcap_vec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaddinuz%2Fcap_vec/lists"}