5 releases

0.2.3 Jun 23, 2023
0.2.2 Sep 26, 2022
0.2.1 Dec 26, 2021
0.2.0 Dec 26, 2021
0.1.0 Dec 26, 2021

#1837 in Development tools

Download history 25/week @ 2024-07-29 26/week @ 2024-09-23 59/week @ 2024-10-14 22/week @ 2024-10-21 30/week @ 2024-10-28 16/week @ 2024-11-04

127 downloads per month

MIT/Apache

12KB
208 lines

pseudonym 🕵️

MSRV 1.56.0

Declare aliases for Rust constructs with ease!

[dependencies]
pseudonym = "0.2.2"

Usage

In the following examples the items to which the macro is attached to get generated as aliases using the passed identifier.

Functions

use pseudonym::alias;

#[alias(short_name)]
fn very_long_function_name() {
    // ...
}

fn main () {
    short_name(); // use the alias!
}

Structures

use pseudonym::alias;

#[alias(StructAlias)]
struct S (i32);

Traits

use pseudonym::alias;

#[alias(TraitAlias)]
trait T {}

Implementations

use pseudonym::alias;

#[alias(StructAlias)]
struct S;

#[alias(StructAlias)]
impl S {
    fn new() -> Self { Self }
}

Constants

use pseudonym::alias;

#[alias(ConstAlias)]
const foo: usize = 0;

Deprecating Aliases

Sometimes, you'll need to create aliases to old functions which are deprecated. pseudonym allows you to deprecate aliases using the same syntax as deprecated.

use pseudonym::alias;

#[alias(
    deprecated(
        old_api_function,
        since = "0.1.0",
        note = "This function has been deprecated in favor of `new_api_function`"
    )
)]
fn new_api_function() {
    // ...
}

fn main () {
    old_api_function(); // use the alias!
}

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~225–670KB
~16K SLoC