arr_ty

Crates.ioarr_ty
lib.rsarr_ty
version0.4.1
created_at2023-04-02 19:00:19.166447+00
updated_at2025-09-28 22:10:33.97881+00
descriptionMacros for smart array initialization.
homepage
repositoryhttps://github.com/nossie531/arr_ty
max_upload_size
id828548
size20,468
(nossie531)

documentation

README

arr_ty

Macros for smart array initialization.

The author of this crate is not good at English.
Forgive me if the document is hard to read.

What is this?

This crate makes Rust array initialization a little smarter.

⚠ Attention!

This crate is useless in the latest version of Rust. generic_arg_infer was introduced in Rust 1.89.0 (2025-08-07). (See rust issue #85077 for more details).

Examples

Use case 1 (number element type)

This is not possible.

let arr = [0, 1, 2] as [u32;_];

With this crate.

let arr = arr_ty!(u32; [0, 1, 2]);

Without this crate, manual counting approach.

let arr = [0, 1, 2] as [u32;3];

Without this crate, redundant type approach.

let arr = [0u32, 1u32, 2u32];

Without this crate, no unity approach.

let arr = [0u32, 1, 2];

Use case 2 (dynamic element type)

This is not possible.

let arr: [Box<dyn Any>; _] = [
    Box::new(0),
    Box::new(false),
    Box::new("false")
];

With this crate.

let arr = arr_ty!(Box<dyn Any>; [
    Box::new(0),
    Box::new(false),
    Box::new("false")
]);

Without this crate, manual counting approach.

let arr: [Box<dyn Any>; 3] = [
    Box::new(0),
    Box::new(false),
    Box::new("false")
];

Without this crate, redundant cast approach.

let arr = [
    Box::new(0) as Box<dyn Any>,
    Box::new(false) as Box<dyn Any>,
    Box::new("false") as Box<dyn Any>
];

Without this crate, no unity approach.

let arr = [
    Box::new(0) as Box<dyn Any>,
    Box::new(false),
    Box::new("false")
];

History

See CHANGELOG.

Commit count: 6

cargo fmt