Skip to content

Commit 15cffc4

Browse files
committed
Clean up a bit
1 parent f11f04d commit 15cffc4

File tree

2 files changed

+13
-75
lines changed

2 files changed

+13
-75
lines changed

derive/src/pyclass.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,6 @@ impl Method {
8989
}
9090
}
9191

92-
/// Parse an impl block into an iterator of methods
93-
fn item_impl_to_methods<'a>(imp: &'a mut syn::ItemImpl) -> impl Iterator<Item = Method> + 'a {
94-
imp.items.iter_mut().filter_map(|item| {
95-
if let ImplItem::Method(meth) = item {
96-
Method::from_syn(&mut meth.attrs, &meth.sig)
97-
} else {
98-
None
99-
}
100-
})
101-
}
102-
10392
pub fn impl_py_class(attr: AttributeArgs, item: Item) -> TokenStream2 {
10493
let mut imp = if let Item::Impl(imp) = item {
10594
imp
@@ -148,7 +137,17 @@ pub fn impl_py_class(attr: AttributeArgs, item: Item) -> TokenStream2 {
148137
}
149138
None => quote!(None),
150139
};
151-
let methods: Vec<_> = item_impl_to_methods(&mut imp).collect();
140+
let methods = imp
141+
.items
142+
.iter_mut()
143+
.filter_map(|item| {
144+
if let ImplItem::Method(meth) = item {
145+
Method::from_syn(&mut meth.attrs, &meth.sig)
146+
} else {
147+
None
148+
}
149+
})
150+
.collect::<Vec<_>>();
152151
let ty = &imp.self_ty;
153152
let methods = methods.iter().map(
154153
|Method {

vm/src/obj/objstr.rs

Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -748,69 +748,8 @@ impl IntoPyObject for String {
748748
}
749749
}
750750

751-
#[rustfmt::skip] // to avoid line splitting
752-
pub fn init(context: &PyContext) {
753-
let str_type = &context.str_type;
754-
755-
PyStringRef::extend_class(context, str_type);
756-
// extend_class!(context, str_type, {
757-
// "__add__" => context.new_rustfunc(PyStringRef::add),
758-
// "__bool__" => context.new_rustfunc(PyStringRef::bool),
759-
// "__contains__" => context.new_rustfunc(PyStringRef::contains),
760-
// "__doc__" => context.new_str(str_doc.to_string()),
761-
// "__eq__" => context.new_rustfunc(PyStringRef::eq),
762-
// "__ge__" => context.new_rustfunc(PyStringRef::ge),
763-
// "__getitem__" => context.new_rustfunc(PyStringRef::getitem),
764-
// "__gt__" => context.new_rustfunc(PyStringRef::gt),
765-
// "__hash__" => context.new_rustfunc(PyStringRef::hash),
766-
// "__lt__" => context.new_rustfunc(PyStringRef::lt),
767-
// "__le__" => context.new_rustfunc(PyStringRef::le),
768-
// "__len__" => context.new_rustfunc(PyStringRef::len),
769-
// "__mul__" => context.new_rustfunc(PyStringRef::mul),
770-
// "__new__" => context.new_rustfunc(str_new),
771-
// "__repr__" => context.new_rustfunc(PyStringRef::repr),
772-
// "__str__" => context.new_rustfunc(PyStringRef::str),
773-
// "capitalize" => context.new_rustfunc(PyStringRef::capitalize),
774-
// "casefold" => context.new_rustfunc(PyStringRef::casefold),
775-
// "center" => context.new_rustfunc(PyStringRef::center),
776-
// "count" => context.new_rustfunc(PyStringRef::count),
777-
// "endswith" => context.new_rustfunc(PyStringRef::endswith),
778-
// "expandtabs" => context.new_rustfunc(PyStringRef::expandtabs),
779-
// "find" => context.new_rustfunc(PyStringRef::find),
780-
// "format" => context.new_rustfunc(str_format),
781-
// "index" => context.new_rustfunc(PyStringRef::index),
782-
// "isalnum" => context.new_rustfunc(PyStringRef::isalnum),
783-
// "isalpha" => context.new_rustfunc(PyStringRef::isalpha),
784-
// "isascii" => context.new_rustfunc(PyStringRef::isascii),
785-
// "isdecimal" => context.new_rustfunc(PyStringRef::isdecimal),
786-
// "isdigit" => context.new_rustfunc(PyStringRef::isdigit),
787-
// "isidentifier" => context.new_rustfunc(PyStringRef::isidentifier),
788-
// "islower" => context.new_rustfunc(PyStringRef::islower),
789-
// "isnumeric" => context.new_rustfunc(PyStringRef::isnumeric),
790-
// "isspace" => context.new_rustfunc(PyStringRef::isspace),
791-
// "isupper" => context.new_rustfunc(PyStringRef::isupper),
792-
// "istitle" => context.new_rustfunc(PyStringRef::istitle),
793-
// "join" => context.new_rustfunc(PyStringRef::join),
794-
// "lower" => context.new_rustfunc(PyStringRef::lower),
795-
// "ljust" => context.new_rustfunc(PyStringRef::ljust),
796-
// "lstrip" => context.new_rustfunc(PyStringRef::lstrip),
797-
// "partition" => context.new_rustfunc(PyStringRef::partition),
798-
// "replace" => context.new_rustfunc(PyStringRef::replace),
799-
// "rfind" => context.new_rustfunc(PyStringRef::rfind),
800-
// "rindex" => context.new_rustfunc(PyStringRef::rindex),
801-
// "rjust" => context.new_rustfunc(PyStringRef::rjust),
802-
// "rpartition" => context.new_rustfunc(PyStringRef::rpartition),
803-
// "rsplit" => context.new_rustfunc(PyStringRef::rsplit),
804-
// "rstrip" => context.new_rustfunc(PyStringRef::rstrip),
805-
// "split" => context.new_rustfunc(PyStringRef::split),
806-
// "splitlines" => context.new_rustfunc(PyStringRef::splitlines),
807-
// "startswith" => context.new_rustfunc(PyStringRef::startswith),
808-
// "strip" => context.new_rustfunc(PyStringRef::strip),
809-
// "swapcase" => context.new_rustfunc(PyStringRef::swapcase),
810-
// "title" => context.new_rustfunc(PyStringRef::title),
811-
// "upper" => context.new_rustfunc(PyStringRef::upper),
812-
// "zfill" => context.new_rustfunc(PyStringRef::zfill),
813-
// });
751+
pub fn init(ctx: &PyContext) {
752+
PyStringRef::extend_class(ctx, &ctx.str_type);
814753
}
815754

816755
pub fn get_value(obj: &PyObjectRef) -> String {

0 commit comments

Comments
 (0)