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

Make struct generated with py_class! public #46

Closed
wants to merge 2 commits into from

Conversation

knsd
Copy link

@knsd knsd commented Apr 18, 2016

So it can be defined not only in lib.rs.

@dgrunwald
Copy link
Owner

I'm not sure if it's a good idea to unconditionally make the type public. I'd like to give the user control over the visibility of the struct. An earlier version of py_class! allowed this using the syntax py_class!{class S} or py_class!{pub class S}, but that feature was lost in the big macro refactoring.
It also leads to some ugly macro code duplication (unless something like RFC #1575 is accepted).

But you don't have to define the type in the crate root (lib.rs): you can also define it in another module, and have that module export a function:

pub fn register_type_in_module(py: Python, m: &PyModule) -> PyResult<()> {
    m.add_type::<MyLocalPrivateType>()
}

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