{"id":14440784,"url":"https://github.com/thomcc/rust-typed-arena","last_synced_at":"2025-12-12T16:55:19.369Z","repository":{"id":30188016,"uuid":"33738737","full_name":"thomcc/rust-typed-arena","owner":"thomcc","description":"The arena, a fast but limited type of allocator","archived":false,"fork":false,"pushed_at":"2024-08-16T05:41:48.000Z","size":78,"stargazers_count":532,"open_issues_count":4,"forks_count":54,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-03-17T11:59:49.380Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/thomcc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2015-04-10T16:28:22.000Z","updated_at":"2025-03-16T19:12:10.000Z","dependencies_parsed_at":"2024-11-05T18:03:35.842Z","dependency_job_id":"f8fef5b9-e0d7-47e7-9279-52e3fa7226e5","html_url":"https://github.com/thomcc/rust-typed-arena","commit_stats":{"total_commits":75,"total_committers":23,"mean_commits":3.260869565217391,"dds":0.7333333333333334,"last_synced_commit":"f1f26c3994dc881c35591cb629d8466df29e778a"},"previous_names":["simonsapin/rust-typed-arena"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomcc%2Frust-typed-arena","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomcc%2Frust-typed-arena/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomcc%2Frust-typed-arena/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomcc%2Frust-typed-arena/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thomcc","download_url":"https://codeload.github.com/thomcc/rust-typed-arena/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247128744,"owners_count":20888235,"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":[],"created_at":"2024-08-31T18:01:37.965Z","updated_at":"2025-12-12T16:55:19.308Z","avatar_url":"https://github.com/thomcc.png","language":"Rust","funding_links":[],"categories":["Rust","Memory Allocator"],"sub_categories":[],"readme":"# `typed-arena`\n\n[![](https://docs.rs/typed-arena/badge.svg)](https://docs.rs/typed-arena)\n[![](https://img.shields.io/crates/v/typed-arena.svg)](https://crates.io/crates/typed-arena)\n[![](https://img.shields.io/crates/d/typed-arena.svg)](https://crates.io/crates/typed-arena)\n[![GitHub Actions Build Status](https://github.com/thomcc/rust-typed-arena/workflows/CI/badge.svg)](https://github.com/thomcc/rust-typed-arena/actions)\n\n**A fast (but limited) allocation arena for values of a single type.**\n\nAllocated objects are destroyed all at once, when the arena itself is destroyed.\nThere is no deallocation of individual objects while the arena itself is still\nalive. The flipside is that allocation is fast: typically just a vector push.\n\nThere is also a method `into_vec()` to recover ownership of allocated objects\nwhen the arena is no longer required, instead of destroying everything.\n\n## Example\n\n```rust\nuse typed_arena::Arena;\n\nstruct Monster {\n    level: u32,\n}\n\nlet monsters = Arena::new();\n\nlet goku = monsters.alloc(Monster { level: 9001 });\nassert!(goku.level \u003e 9000);\n```\n\n## Safe Cycles\n\nAll allocated objects get the same lifetime, so you can safely create cycles\nbetween them. This can be useful for certain data structures, such as graphs and\ntrees with parent pointers.\n\n```rust\nuse std::cell::Cell;\nuse typed_arena::Arena;\n\nstruct CycleParticipant\u003c'a\u003e {\n    other: Cell\u003cOption\u003c\u0026'a CycleParticipant\u003c'a\u003e\u003e\u003e,\n}\n\nlet arena = Arena::new();\n\nlet a = arena.alloc(CycleParticipant { other: Cell::new(None) });\nlet b = arena.alloc(CycleParticipant { other: Cell::new(None) });\n\na.other.set(Some(b));\nb.other.set(Some(a));\n```\n\n## Alternatives\n\n### Need to allocate many different types of values?\n\nUse multiple arenas if you have only a couple different types or try\n[`bumpalo`](https://crates.io/crates/bumpalo), which is a bump-allocation arena\nthat can allocate heterogenous types of values.\n\n### Want allocation to return identifiers instead of references and dealing with references and lifetimes everywhere?\n\nCheck out [`id-arena`](https://crates.io/crates/id-arena) or\n[`generational-arena`](https://crates.io/crates/generational-arena).\n\n### Need to deallocate individual objects at a time?\n\nCheck out [`generational-arena`](https://crates.io/crates/generational-arena)\nfor an arena-style crate or look for a more traditional allocator.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomcc%2Frust-typed-arena","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomcc%2Frust-typed-arena","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomcc%2Frust-typed-arena/lists"}