{"id":21361589,"url":"https://github.com/acovaci/expand-array-rust-macro","last_synced_at":"2025-03-16T06:44:12.550Z","repository":{"id":240210200,"uuid":"801983159","full_name":"acovaci/expand-array-rust-macro","owner":"acovaci","description":"Arrr! macro for easy fixed-size array creation from slices and strings. Fill gaps with any value or zero.","archived":false,"fork":false,"pushed_at":"2024-05-18T02:30:16.000Z","size":45,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T15:11:13.411Z","etag":null,"topics":["array","c-ffi","crate","crates-io","developer-tools","ffi","macro","proc-macro","proc-macro2","rust","rust-ffi","static"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/expand_array","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/acovaci.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}},"created_at":"2024-05-17T09:37:22.000Z","updated_at":"2024-05-19T17:15:14.000Z","dependencies_parsed_at":"2024-05-17T10:49:48.222Z","dependency_job_id":"1301a1f1-3527-4118-97fa-b35953beb7d1","html_url":"https://github.com/acovaci/expand-array-rust-macro","commit_stats":null,"previous_names":["acovaci/expand-array-rust-macro"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acovaci%2Fexpand-array-rust-macro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acovaci%2Fexpand-array-rust-macro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acovaci%2Fexpand-array-rust-macro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acovaci%2Fexpand-array-rust-macro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/acovaci","download_url":"https://codeload.github.com/acovaci/expand-array-rust-macro/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243835937,"owners_count":20355611,"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":["array","c-ffi","crate","crates-io","developer-tools","ffi","macro","proc-macro","proc-macro2","rust","rust-ffi","static"],"created_at":"2024-11-22T06:10:27.429Z","updated_at":"2025-03-16T06:44:12.529Z","avatar_url":"https://github.com/acovaci.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Expand Array Rust Macro\n\n![](https://img.shields.io/github/actions/workflow/status/acovaci/expand-array-rust-macro/rust.yml)\n[![](https://img.shields.io/crates/v/expand-array)\n](https://crates.io/crates/expand-array)\n[![](https://img.shields.io/crates/d/expand-array)\n](https://crates.io/crates/expand-array)\n[![](https://img.shields.io/crates/l/expand-array)\n](https://crates.io/crates/expand-array)\n[![](https://docs.rs/expand_array/badge.svg)\n](https://docs.rs/expand-array)\n\nThis crate provides a macro called `arr!` to convert a static array to a\nfixed-size array. Limited type conversion is supported. This is useful when you\nneed to make available global constants in a dynamic library, for example.\n\nAs a bonus, the crate also provides a `bitify!` macro to convert a string\nliteral to a fixed-size array of bytes.\n\n## Usage\n\nThe `arr!` macro can take any two primitive types. On top of that, it can take\nstring literals (`\u0026str`, byte strings and C strings). Using the `bitify!` macro,\nit can convert it to a fixed-size array of any primitive type.\n\n```rust\nuse expand_array::arrr;\n\nlet var: [\u003ctarget_type\u003e; target_len] = arrr!(\u003csource\u003e as [\u003ctarget_type\u003e; target_len]);\nlet var_with_default: [\u003ctarget_type\u003e; target_len] = arrr!(\u003csource\u003e as [\u003ctarget_type\u003e; target_len] with \u003cdefault_value\u003e);\n```\n\n## Example\n\n```rust\nuse expand_array::arrr;\n\nlet arr: [u8; 10] = arrr!([1, 2, 3, 4, 5] as [u8; 10]);\nassert_eq!(arr, [1, 2, 3, 4, 5, 0, 0, 0, 0, 0]);\n\nlet arr: [u8; 10] = arrr!([1, 2, 3, 4, 5] as [u8; 10] with 2);\nassert_eq!(arr, [1, 2, 3, 4, 5, 2, 2, 2, 2, 2]);\n\nlet arr: [u8; 10] = arrr!(b\"Hello\" as [u8; 10]);\nassert_eq!(arr, [72, 101, 108, 108, 111, 0, 0, 0, 0, 0]);\n\nlet arr: [u8; 10] = arrr!(\"Hello\" as [u8; 10]);\nassert_eq!(arr, [72, 101, 108, 108, 111, 0, 0, 0, 0, 0]);\n\nlet arr: [char; 10] = arrr!(['H', 'e', 'l', 'l', 'o'] as [char; 10]);\nassert_eq!(arr, ['H', 'e', 'l', 'l', 'o', '\\0', '\\0', '\\0', '\\0', '\\0']);\n\nlet arr: [\u0026str; 10] = arrr!([\"Hello\", \"world\"] as [\u0026str; 10] with '!');\nassert_eq!(arr, [\"Hello\", \"world\", \"!\", \"!\", \"!\", \"!\", \"!\", \"!\", \"!\", \"!\"]);\n\nuse ::std::ffi::c_char;\n\nlet arr: [c_char; 10] = arrr!([72i8, 101, 108, 108, 111] as [c_char; 10]);\nassert_eq!(arr, [72i8, 101, 108, 108, 111, 0, 0, 0, 0, 0]);\n\nlet arr: [c_char; 10] = arrr!(c\"Hello\" as [c_char; 10]);\nassert_eq!(arr, [72i8, 101, 108, 108, 111, 0, 0, 0, 0, 0]);\n\nlet arr: [c_char; 10] = arrr!([72u8, 101, 108, 108, 111] as [c_char; 10]);\nassert_eq!(arr, [72i8, 101, 108, 108, 111, 0, 0, 0, 0, 0]);\n\nlet arr: [c_char; 10] = arrr!([b'H', b'e', b'l', b'l', b'o'] as [c_char; 10]);\nassert_eq!(arr, [72i8, 101, 108, 108, 111, 0, 0, 0, 0, 0]);\n\nlet arr: [c_char; 10] = arrr!(b\"Hello\" as [c_char; 10]);\nassert_eq!(arr, [72i8, 101, 108, 108, 111, 0, 0, 0, 0, 0]);\n\nlet arr: [c_char; 10] = arrr!(\"Hello\" as [c_char; 10] with \"!\");\nassert_eq!(arr, [72i8, 101, 108, 108, 111, 33, 33, 33, 33, 33]);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facovaci%2Fexpand-array-rust-macro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facovaci%2Fexpand-array-rust-macro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facovaci%2Fexpand-array-rust-macro/lists"}