Crates.io | rename |
lib.rs | rename |
version | 0.1.1 |
source | src |
created_at | 2020-05-23 17:25:16.496345 |
updated_at | 2020-08-12 18:06:38.169284 |
description | Easy modification of structure names |
homepage | |
repository | https://github.com/not-matthias/rename_derive/ |
max_upload_size | |
id | 244937 |
size | 10,315 |
Easy modification of structure names.
#[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
.
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.