{"id":13595598,"url":"https://github.com/JoshMcguigan/arr_macro","last_synced_at":"2025-04-09T13:32:44.164Z","repository":{"id":45294516,"uuid":"162860944","full_name":"JoshMcguigan/arr_macro","owner":"JoshMcguigan","description":"Initialize arrays with ease!","archived":false,"fork":false,"pushed_at":"2023-01-05T22:25:45.000Z","size":15,"stargazers_count":84,"open_issues_count":3,"forks_count":5,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-04-24T09:19:51.561Z","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/JoshMcguigan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-23T04:03:15.000Z","updated_at":"2024-02-02T08:21:48.000Z","dependencies_parsed_at":"2023-02-04T20:45:31.978Z","dependency_job_id":null,"html_url":"https://github.com/JoshMcguigan/arr_macro","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoshMcguigan%2Farr_macro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoshMcguigan%2Farr_macro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoshMcguigan%2Farr_macro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoshMcguigan%2Farr_macro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JoshMcguigan","download_url":"https://codeload.github.com/JoshMcguigan/arr_macro/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223394630,"owners_count":17138588,"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-01T16:01:53.166Z","updated_at":"2024-11-06T18:31:19.651Z","avatar_url":"https://github.com/JoshMcguigan.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# Array Macro [![Build Status](https://api.travis-ci.org/JoshMcguigan/arr_macro.svg?branch=master)](https://travis-ci.org/JoshMcguigan/arr_macro) [![crates.io badge](https://img.shields.io/crates/v/arr_macro.svg)](https://crates.io/crates/arr_macro)\n\nArray macro helps initialize arrays. It is useful when initializing large arrays (greater than 32 elements), or arrays of types which do not implement the copy or default traits. \n\nArray macro is implemented in 100% safe Rust.\n\nFor further background on the motivation behind this crate, check out [this blog post](https://www.joshmcguigan.com/blog/array-initialization-rust/).\n\n## Usage\n\n```rust\nuse arr_macro::arr;\n\nfn main() {\n    let x: [Option\u003cString\u003e; 3] = arr![None; 3];\n    assert_eq!(\n        [None, None, None],\n        x\n    );\n\n    // works with all enum types (and impl copy is not required)\n    #[allow(dead_code)]\n    enum MyEnum {\n        A,\n        B\n    }\n    let _: [MyEnum; 33] = arr![MyEnum::A; 33];\n\n    // Vec::new()\n    let _: [Vec\u003cString\u003e; 33] = arr![Vec::new(); 33];\n\n    // or your own struct type\n    // and you can even use a counter to behave differently based on the array index\n    #[derive(Debug)]\n    struct MyStruct {\n        member: u16,\n    }\n    impl MyStruct {\n        fn new(member: u16) -\u003e Self {\n            MyStruct { member }\n        }\n    }\n    let mut i = 0u16;\n    let x: [MyStruct; 33] = arr![MyStruct::new({i += 1; i - 1}); 33];\n\n    assert_eq!(0, x[0].member);\n    assert_eq!(1, x[1].member);\n    assert_eq!(2, x[2].member);\n}\n```\n\n## License\n\nLicensed under either of\n\n * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([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 for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJoshMcguigan%2Farr_macro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJoshMcguigan%2Farr_macro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJoshMcguigan%2Farr_macro/lists"}