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 the Collect trait part of the public api #5

Closed
konstin opened this issue Jan 30, 2019 · 2 comments
Closed

Make the Collect trait part of the public api #5

konstin opened this issue Jan 30, 2019 · 2 comments

Comments

@konstin
Copy link

konstin commented Jan 30, 2019

It's currently not possible to write a function generic over Twhere T is an inventory.

To rewrite the example given in the docs page:

fn print_inventory<T: inventory::Collect>() {
    for flag in inventory::iter::<T> {
        println!("-{}, --{}", flag.short, flag.name);
    }
}

This does already work, but the Collect trait is currently #[doc(hidden)]. My specific use case is doing the following, combined with two proc macros and a helper traits:

/// Allows arbitrary pymethod blocks to submit their methods, which are eventually collected by pyclass
pub trait PyMethodsInventory: inventory::Collect {
    /// Create a new instance
    fn new(methods: &'static [PyMethodDefType]) -> Self;

    /// Returns the methods for a single impl block
    fn get_methods(&self) -> &'static [PyMethodDefType];
}
@dtolnay
Copy link
Owner

dtolnay commented Jan 31, 2019

Fixed in 0.1.3.

@konstin
Copy link
Author

konstin commented Feb 1, 2019

Thank you!

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