#alias #impl-block #type #impl

macro local-type-alias

Local type aliases in impl blocks

5 releases

0.1.5 Mar 4, 2024
0.1.4 Feb 26, 2024

#1221 in Rust patterns

Download history 261/week @ 2024-02-19 200/week @ 2024-02-26 145/week @ 2024-03-04 16/week @ 2024-03-11 103/week @ 2024-04-01

125 downloads per month

MIT license

18KB
389 lines

Local type aliases

local-type-alias provides an attribute macro for creating scoped type and trait aliases in an item.

Examples

#[local_alias]
#[alias(type X = i32)]
struct MyType<T>
where
    X: for<'a> Add<&'a T>,
{
    value: T,
}
#[local_alias]
#[alias(
    type X = [T; 4],
    type Y = *mut X,
    type Z = fn(X) -> Y,
    trait A = PartialEq<fn([u8; 4]) -> *mut [u8; 4]>,
)]
impl<T> MyType<T>
where
    Z: A,
{
    // ...
}

lib.rs:

local-type-aliases allows for the creation of scoped type and trait aliases in an item.

Examples

#
#
#[local_alias]
#[alias(type X = i32)]
struct MyType<T>
where
    X: for<'a> Add<&'a T>,
{
    value: T,
}
#
#
#[local_alias]
#[alias(
    type X = [u8; 4],
    type Y = *mut X,
    type Z = fn(X) -> Y,
    trait A = PartialEq<fn([u8; 4]) -> *mut X>,
)]
impl<T> MyType<T>
where
    Z: A,
{
    // ...
}

Dependencies

~330–780KB
~19K SLoC