{"id":18016914,"url":"https://github.com/fitzgen/id-arena","last_synced_at":"2025-04-04T14:07:52.643Z","repository":{"id":60775534,"uuid":"157155145","full_name":"fitzgen/id-arena","owner":"fitzgen","description":"A simple, id-based arena","archived":false,"fork":false,"pushed_at":"2023-08-30T07:40:48.000Z","size":35,"stargazers_count":119,"open_issues_count":3,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-04T05:37:23.808Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fitzgen.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":"2018-11-12T04:11:31.000Z","updated_at":"2025-03-31T05:30:55.000Z","dependencies_parsed_at":"2024-06-19T00:25:40.918Z","dependency_job_id":null,"html_url":"https://github.com/fitzgen/id-arena","commit_stats":{"total_commits":32,"total_committers":3,"mean_commits":"10.666666666666666","dds":0.1875,"last_synced_commit":"473ce264f1d84185cec3795d1fd5517cf66a7d3c"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Fid-arena","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Fid-arena/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Fid-arena/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Fid-arena/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fitzgen","download_url":"https://codeload.github.com/fitzgen/id-arena/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247128739,"owners_count":20888234,"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-10-30T04:19:41.092Z","updated_at":"2025-04-04T14:07:52.627Z","avatar_url":"https://github.com/fitzgen.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `id-arena`\n\n[![](https://img.shields.io/crates/v/id-arena.svg)](https://crates.io/crates/id-arena)\n[![](https://img.shields.io/crates/d/id-arena.svg)](https://crates.io/crates/id-arena)\n[![Travis CI Build Status](https://travis-ci.org/fitzgen/id-arena.svg?branch=master)](https://travis-ci.org/fitzgen/id-arena)\n\nA simple, id-based arena.\n\n### Id-based\n\nAllocate objects and get an identifier for that object back, *not* a\nreference to the allocated object. Given an id, you can get a shared or\nexclusive reference to the allocated object from the arena. This id-based\napproach is useful for constructing mutable graph data structures.\n\nIf you want allocation to return a reference, consider [the `typed-arena`\ncrate](https://github.com/SimonSapin/rust-typed-arena/) instead.\n\n### No Deletion\n\nThis arena does not support deletion, which makes its implementation simple\nand allocation fast. If you want deletion, you need a way to solve the ABA\nproblem. Consider using [the `generational-arena`\ncrate](https://github.com/fitzgen/generational-arena) instead.\n\n### Homogeneous\n\nThis crate's arenas can only contain objects of a single type `T`. If you\nneed an arena of objects with heterogeneous types, consider another crate.\n\n### `#![no_std]` Support\n\nRequires the `alloc` nightly feature. Disable the on-by-default `\"std\"` feature:\n\n```toml\n[dependencies.id-arena]\nversion = \"2\"\ndefault-features = false\n```\n\n### `rayon` Support\n\nIf the `rayon` feature of this crate is activated:\n\n```toml\n[dependencies]\nid-arena = { version = \"2\", features = [\"rayon\"] }\n```\n\nthen you can use [`rayon`](https://crates.io/crates/rayon)'s support for\nparallel iteration. The `Arena` type will have a `par_iter` family of\nmethods where appropriate.\n\n### Example\n\n```rust\nuse id_arena::{Arena, Id};\n\ntype AstNodeId = Id\u003cAstNode\u003e;\n\n#[derive(Debug, Eq, PartialEq)]\npub enum AstNode {\n    Const(i64),\n    Var(String),\n    Add {\n        lhs: AstNodeId,\n        rhs: AstNodeId,\n    },\n    Sub {\n        lhs: AstNodeId,\n        rhs: AstNodeId,\n    },\n    Mul {\n        lhs: AstNodeId,\n        rhs: AstNodeId,\n    },\n    Div {\n        lhs: AstNodeId,\n        rhs: AstNodeId,\n    },\n}\n\nlet mut ast_nodes = Arena::\u003cAstNode\u003e::new();\n\n// Create the AST for `a * (b + 3)`.\nlet three = ast_nodes.alloc(AstNode::Const(3));\nlet b = ast_nodes.alloc(AstNode::Var(\"b\".into()));\nlet b_plus_three = ast_nodes.alloc(AstNode::Add {\n    lhs: b,\n    rhs: three,\n});\nlet a = ast_nodes.alloc(AstNode::Var(\"a\".into()));\nlet a_times_b_plus_three = ast_nodes.alloc(AstNode::Mul {\n    lhs: a,\n    rhs: b_plus_three,\n});\n\n// Can use indexing to access allocated nodes.\nassert_eq!(ast_nodes[three], AstNode::Const(3));\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffitzgen%2Fid-arena","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffitzgen%2Fid-arena","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffitzgen%2Fid-arena/lists"}