Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customized generation: ordering customized code at the top of message #675

Closed
vaikzs opened this issue Jun 11, 2023 · 0 comments
Closed

Comments

@vaikzs
Copy link
Contributor

vaikzs commented Jun 11, 2023

When registering for trait protobuf_codegen::CustomizeCallback for messages. Derive macros with implemented by structs converted from protobuf messages are placed at first line.

This is probably a design decision to consider only custom derive macros to be added before struct. However I have a scenario where custom implementation for struct has to be added.

Example scenario

message Animal {
  string dog = 1; 
}

generated struct

Struct Animal {}

Lets say -- assume following code block has to be placed before struct Animal

impl Animal {
    pub fn  dog() { 
       todo!()   
    }
}

then current protobuf-codegen when writing derives for each struct generates the following:

#[derive(PartialEq, Clone, Default, Debug)]
impl Animal {
    pub fn  dog() { 
       todo!()   
    }
}

struct Animal {} 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants