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

Add NaifId newtype and mapping to bodies #18

Merged
merged 6 commits into from
Nov 15, 2023
Merged

Add NaifId newtype and mapping to bodies #18

merged 6 commits into from
Nov 15, 2023

Conversation

helgee
Copy link
Member

@helgee helgee commented Nov 13, 2023

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.

Copy link
Contributor

@AngusGMorrison AngusGMorrison left a 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.

crates/lox_core/src/bodies.rs Show resolved Hide resolved
/// NaifId is implemented for all bodies.
pub trait NaifId: Copy {
const ID: i32;
pub trait Body {
Copy link
Contributor

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 🙂

crates/lox_core/src/bodies.rs Show resolved Hide resolved
@helgee
Copy link
Member Author

helgee commented Nov 14, 2023

Could you please also reimplement lox_gen::naif_ids in terms of these newly box-able bodies? Currently we have two sources of truth.

Done

@helgee helgee merged commit 6a19a42 into main Nov 15, 2023
20 checks passed
@helgee helgee deleted the he/dyn-body branch November 15, 2023 11:02
This was referenced Jul 19, 2024
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

Successfully merging this pull request may close these issues.

2 participants