rename_derive

Crates.iorename_derive
lib.rsrename_derive
version0.1.0
sourcesrc
created_at2020-05-02 19:51:45.491572
updated_at2020-05-02 19:51:45.491572
descriptionEasy modification of structure names
homepage
repositoryhttps://github.com/not-matthias/rename_derive/
max_upload_size
id236777
size45,625
Matthias (not-matthias)

documentation

README

rename_derive

crates.io crates.io docs.rs Lines of Code GPLv3 license

Easy modification of structure names.

Example

#[rename(prepend = "One", name = "Two", append = "Three")]
struct Placeholder {
    pub one: u64,
    pub two: u64,
    pub three: u64
}

The name of the struct is now OneTwoThree.

Why?

When working with declarative macros you can't create new idents. You could also remove this problem by using a proc-macro, but this would increase the complexity. However, there's the macro concat_idents which allows you to, as you can probably guess, concat identifiers. The big problem with this macro is, that it's not yet stable and doesn't allow the creation of new identifiers. Thus I decided to create my own little helper crate that solves this problem.

The implementation for the aforementioned problem can be found here.

Commit count: 31

cargo fmt