-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add NaifId newtype and mapping to bodies #18
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great. Should be much smoother to work with bodies as a general category of object.
If you haven't read it already, I highly recommend Rust for Rustaceans, which covers object safety well (and much more besides). It's a bit light on examples, but very well written.
Could you please also reimplement lox_gen::naif_ids in terms of these newly box-able bodies? Currently we have two sources of truth.
/// NaifId is implemented for all bodies. | ||
pub trait NaifId: Copy { | ||
const ID: i32; | ||
pub trait Body { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm much happier with this implementation 🙂
Done |
It was quite the headache to make the body ZST object-safe but I was successful. Since neither associated constants nor static methods are allowed for trait objects, I needed to go back to instance methods. Unfortunately, this may be required in other places as well.