#impl-block #alias #impl #type

macro local-type-alias

Local type aliases in impl blocks

5 releases

0.1.5 Mar 4, 2024
0.1.4 Feb 26, 2024

#18 in #impl-block


Used in peano-axioms

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

~235–680KB
~16K SLoC