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

Reexport yaxpeax-arch #10

Open
i509VCB opened this issue Oct 11, 2021 · 2 comments
Open

Reexport yaxpeax-arch #10

i509VCB opened this issue Oct 11, 2021 · 2 comments

Comments

@i509VCB
Copy link
Contributor

i509VCB commented Oct 11, 2021

Since Instruction::len() requires importing a trait from yaxpeax-arch and the arch crate is a required dependency it may make sense to reexport yaxpeax-arch inside of this crate and the other architecture crates.

Reexports would involve adding a pub use yaxpeax_arch; statement to the lib.rs. Adding an as <whatever> as suitable to make sense in the crate structure.

This would allow users to not have to explicitly declare yaxpeax-arch in their Cargo.toml's dependencies while still being able to use the arch types.

@iximeow
Copy link
Owner

iximeow commented Oct 13, 2021

this seems like good advice for any implementors of yaxpeax-arch, yeah. it might also make sense to re-export num_traits::Zero or at least provide functions like zero() and one() on Address

Adding an as <whatever> as suitable to make sense in the crate structure.

i'm not sure i follow. pub use yaxpeax_arch; ought to allow users to write use yaxpeax_x86::LengthedInstruction and call Instruction::len() without thinking about the actual yaxpeax-arch crate. is there a renaming that would make sense to you?

(as an aside, this issue has me rethinking the idea that an instruction could not have a len(). it seemed like a less safe requirement before the Reader trait, now a ptrdiff_t-style number of words is more clearly expressible.)

@i509VCB
Copy link
Contributor Author

i509VCB commented Oct 13, 2021

Hmm how to approach that is a good question.

You could introduce a sort of prelude module to yaxpeax-arch and just reexport the contents of the prelude in yaxpeax-x86 to avoid needing to declare imports using yaxpeax_x86::yaxpeax_arch::LengthedInstruction.

With the prelude contents being reexported, users would just use use yaxpeax_x86::LengthenedInstruction

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