Coder Social home page Coder Social logo

pseudonym's Introduction

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.

pseudonym's People

Contributors

haennes avatar jmg-duarte avatar

Stargazers

 avatar  avatar

Watchers

 avatar

pseudonym's Issues

Review the CI

All tests need to pass and ideally the deprecation warnings should be shutdown as they are precisely what is being tested

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.