{"id":28455680,"url":"https://github.com/questdb/alloc-checked","last_synced_at":"2025-06-27T02:31:31.702Z","repository":{"id":257808301,"uuid":"861652934","full_name":"questdb/alloc-checked","owner":"questdb","description":"Rust collections that don't panic on alloc failures","archived":false,"fork":false,"pushed_at":"2024-11-11T12:53:49.000Z","size":38,"stargazers_count":3,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-06T22:11:16.710Z","etag":null,"topics":["allocation","collections","nostd","rust"],"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/questdb.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-23T09:37:34.000Z","updated_at":"2024-11-11T12:18:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"cb98a555-cf67-43c6-b78b-ce6e440a03f0","html_url":"https://github.com/questdb/alloc-checked","commit_stats":null,"previous_names":["questdb/alloc-checked"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/questdb/alloc-checked","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/questdb%2Falloc-checked","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/questdb%2Falloc-checked/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/questdb%2Falloc-checked/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/questdb%2Falloc-checked/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/questdb","download_url":"https://codeload.github.com/questdb/alloc-checked/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/questdb%2Falloc-checked/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262177632,"owners_count":23270905,"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":["allocation","collections","nostd","rust"],"created_at":"2025-06-06T22:10:21.566Z","updated_at":"2025-06-27T02:31:31.694Z","avatar_url":"https://github.com/questdb.png","language":"Rust","readme":"# Overview\n\nThe `alloc-checked` crate provides wrapper types for common collections that require an explicit allocator and\nreturn a `Result` instead of panicking on allocation failure.\n\nThe wrapper collection types provide two main benefits:\n* They can't be used incorrectly by virtue of lacking APIs which panic.\n* Provide additional convenience methods for working with the collection in a checked manner.\n\n## Restrictions\n\nThe crate requires a recent build of the Rust \"nightly\" compiler, as it uses the\n[`allocator_api`](https://doc.rust-lang.org/std/alloc/trait.Allocator.html) feature.\n\n## No Std\n\nBy default, the crate compiles against the Rust standard library.\n\nThe crate is also `#![no_std]` compatible via the `no_std` feature.\nWhen compiled in `no_std` mode, it still relies on the `alloc`, `core` crates.\n\n## Usage\n\nAdd the dependency\n\n```bash\ncargo add alloc-checked # --features no_std\n```\n\nChances are you might have been using `Vec` in a few places. Import the type you need\n\n```rust\nuse alloc_checked::vec::Vec;\n\nlet vec = Vec::new_in(your_allocator);\nvec.push(42)?;  // -\u003e Result\u003c(), TryReserveError\u003e\n```\n\nand fix any resulting compile errors.\n\nAlong the way, you probably want to implement the `From` trait for your error type to make it easier to bubble up\nallocation errors.\n\n```rust\nuse alloc::AllocError;\nuse alloc::collections::TryReserveError;\n\nimpl From\u003cAllocError\u003e for YourErrorType { /* ... */ }\nimpl From\u003cTryReserveError\u003e for YourErrorType { /* ... */ }\n\n```\n\n## Current state of the project and design philosophy\n\nWe (QuestDB) are adding to this crate on a per-need basis. There's currently decent support for the `Vec` type,\nwith more types to come. Contributions are quite welcome even if they extend beyond our needs.\n\nThe core design philosophy here is that it should never be possible to use this crate in a way that it silently\nallocates memory. Having a different type that can't be misused also allows for improved API ergonomics. \n\nAs a small example, std's `Vec` has both `fn with_capacity_in(alloc: Allocator) -\u003e Vec` and\n`fn try_with_capacity_in(alloc: Allocator) -\u003e Result\u003cVec, TryReserveError\u003e` variants.\n\nThe `Vec` implementation in `alloc-checked` has a single `fn with_capacity_in(alloc: Allocator) -\u003e Vec`,\nlikewise many common methods that silently panic in the standard library, here return a `Result` instead with the idea\nof an easier code migration.\n\n## License\n\nLicensed under either of\n\n* Apache License, Version 2.0\n  ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n* MIT license\n  ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquestdb%2Falloc-checked","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquestdb%2Falloc-checked","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquestdb%2Falloc-checked/lists"}