Crates.io | pseudonym |
lib.rs | pseudonym |
version | 0.2.3 |
source | src |
created_at | 2021-12-26 13:50:27.992858 |
updated_at | 2023-06-23 15:38:24.596867 |
description | Declare aliases with ease! |
homepage | https://github.com/jmg-duarte/pseudonym |
repository | https://github.com/jmg-duarte/pseudonym |
max_upload_size | |
id | 503295 |
size | 22,237 |
Declare aliases for Rust constructs with ease!
[dependencies]
pseudonym = "0.2.2"
In the following examples the items to which the macro is attached to get generated as aliases using the passed identifier.
use pseudonym::alias;
#[alias(short_name)]
fn very_long_function_name() {
// ...
}
fn main () {
short_name(); // use the alias!
}
use pseudonym::alias;
#[alias(StructAlias)]
struct S (i32);
use pseudonym::alias;
#[alias(TraitAlias)]
trait T {}
use pseudonym::alias;
#[alias(StructAlias)]
struct S;
#[alias(StructAlias)]
impl S {
fn new() -> Self { Self }
}
use pseudonym::alias;
#[alias(ConstAlias)]
const foo: usize = 0;
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!
}