iter type: Added __doc__

This commit is contained in:
ZapAnton
2019-02-08 18:56:34 +03:00
parent 07fd61f55f
commit e6d638d43f

View File

@@ -161,6 +161,13 @@ fn iter_next(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
pub fn init(context: &PyContext) {
let iter_type = &context.iter_type;
let iter_doc = "iter(iterable) -> iterator\n\
iter(callable, sentinel) -> iterator\n\n\
Get an iterator from an object. In the first form, the argument must\n\
supply its own iterator, or be a sequence.\n\
In the second form, the callable is called until it returns the sentinel.";
context.set_attr(
&iter_type,
"__contains__",
@@ -169,4 +176,5 @@ pub fn init(context: &PyContext) {
context.set_attr(&iter_type, "__iter__", context.new_rustfunc(iter_iter));
context.set_attr(&iter_type, "__new__", context.new_rustfunc(iter_new));
context.set_attr(&iter_type, "__next__", context.new_rustfunc(iter_next));
context.set_attr(&iter_type, "__doc__", context.new_str(iter_doc.to_string()));
}