-
Notifications
You must be signed in to change notification settings - Fork 760
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
Unify PyMethodsInventoryDispatch and PyMethodsProtocol #889
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.
It's a nice simplification! I had a couple of ideas for names, ignore if you prefer what is already there.
@@ -213,7 +213,7 @@ fn parse_descriptors(item: &mut syn::Field) -> syn::Result<Vec<FnType>> { | |||
fn impl_inventory(cls: &syn::Ident) -> TokenStream { | |||
// Try to build a unique type that gives a hint about it's function when | |||
// it comes up in error messages | |||
let name = cls.to_string() + "GeneratedPyo3Inventory"; | |||
let name = format!("Pyo3MethodsInventoryFor{}", cls); |
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.
let name = format!("Pyo3MethodsInventoryFor{}", cls); | |
let name = format!("PyMethodsOf{}", cls); |
Longer name is also fine, just wondered if I could find a shorter one which worked.
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.
Since this is a generated struct, I think it's better if a user can understand that this is generated from the name if he or she uses cargo expand
.
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.
That's fair. PyO3GeneratedMethodsFor{}
? Your choice of name is also fine.
src/class/methods.rs
Outdated
#[doc(hidden)] // Only to be used through the proc macros | ||
/// For pyclass derived structs, this trait collects method from all impl blocks using inventory. |
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.
Usually I put attributes after doc? Maybe it doesn't work for #[doc(hidden)]
#[doc(hidden)] // Only to be used through the proc macros | |
/// For pyclass derived structs, this trait collects method from all impl blocks using inventory. | |
/// For pyclass derived structs, this trait collects method from all impl blocks using inventory. | |
#[doc(hidden)] // Only to be used through the proc macros |
We probably need a |
PyMethodProtocol
is exposed as a public API, but it is actually really difficult to use without proc-macro.So I decided to unify
PyMethodsInventoryDispatch
andPyMethodsProtocol
, yieldingPyMethodsImpl
.Since we need more inventory-related types to remove specialization, I think we need this kind of simplification not to make our code too complex.