Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jmg-duarte/pseudonym
Declare aliases with ease!
https://github.com/jmg-duarte/pseudonym
deprecate macros proc-macro rust
Last synced: 3 months ago
JSON representation
Declare aliases with ease!
- Host: GitHub
- URL: https://github.com/jmg-duarte/pseudonym
- Owner: jmg-duarte
- Created: 2021-12-25T16:45:36.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-03T15:05:29.000Z (over 1 year ago)
- Last Synced: 2024-09-13T20:09:23.657Z (4 months ago)
- Topics: deprecate, macros, proc-macro, rust
- Language: Rust
- Homepage: https://docs.rs/pseudonym/
- Size: 49.8 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pseudonym 🕵️
Declare aliases for Rust constructs with ease!
```toml
[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
```rust
use pseudonym::alias;#[alias(short_name)]
fn very_long_function_name() {
// ...
}fn main () {
short_name(); // use the alias!
}
```### Structures
```rust
use pseudonym::alias;#[alias(StructAlias)]
struct S (i32);
```### Traits
```rust
use pseudonym::alias;#[alias(TraitAlias)]
trait T {}
```### Implementations
```rust
use pseudonym::alias;#[alias(StructAlias)]
struct S;#[alias(StructAlias)]
impl S {
fn new() -> Self { Self }
}
```### Constants
```rust
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`.```rust
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.