Skip to content

Spartan2909/local-type-alias

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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,
{
    // ...
}
#[local_alias(macros)]
#[alias(type TotallyNotAString = String)]
struct MyType {
   // This expands to `value: my_macro!(String),`
   value: my_macro!({{TotallyNotAString}}),
}