Replies: 1 comment 1 reply
-
It's possible to define impl blocks for types in other modules which seems to me like a pretty good approach for what I understand you to be trying to do. Eg In a file named #[derive(Default)]
pub(crate) struct Meow {
pub(crate) count: u64
} In a file named impl super::entity::Meow {
pub(crate) fn inc(&mut self) {
self.count += 1;
}
pub(crate) fn get(&self) -> u64 {
self.count
}
} in a file named mod entity;
mod entity_extensions;
use entity::Meow;
fn main() {
let mut m = Meow::default();
m.inc();
m.inc();
m.inc();
println!("Hello, {}!", m.get());
} For me this code produces the expected output:
With this approach you can put your entity extensions anywhere else in your crate. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
After discussions on Discord I have added a feature request that I am happy to code if the project is willing to accept it.
See Update entity generation to preserve customisations #1931
I note that there have been multiple discussions on this topic in the past. For example:
Thanks
Dave
Beta Was this translation helpful? Give feedback.
All reactions