mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Added __doc__ atrribute for tuple
This commit is contained in:
1 parent
3d2d04596c
commit
b85cf91a23
2 files changed
+11
No files matched your search
@@ -19,3 +19,5 @@ assert x > y, "tuple __gt__ failed"
|
||||
|
||||
b = (1,2,3)
|
||||
assert b.index(2) == 1
|
||||
|
||||
assert b.__doc__ == "tuple() -> empty tuple\ntuple(iterable) -> tuple initialized from iterable's items\n\nIf the argument is a tuple, the return value is the same object."
|
||||
@@ -290,6 +290,10 @@ pub fn tuple_contains(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
|
||||
pub fn init(context: &PyContext) {
|
||||
let tuple_type = &context.tuple_type;
|
||||
let tuple_doc = "tuple() -> empty tuple
|
||||
tuple(iterable) -> tuple initialized from iterable's items
|
||||
|
||||
If the argument is a tuple, the return value is the same object.";
|
||||
context.set_attr(&tuple_type, "__add__", context.new_rustfunc(tuple_add));
|
||||
context.set_attr(&tuple_type, "__eq__", context.new_rustfunc(tuple_eq));
|
||||
context.set_attr(
|
||||
@@ -313,5 +317,10 @@ pub fn init(context: &PyContext) {
|
||||
context.set_attr(&tuple_type, "__le__", context.new_rustfunc(tuple_le));
|
||||
context.set_attr(&tuple_type, "__gt__", context.new_rustfunc(tuple_gt));
|
||||
context.set_attr(&tuple_type, "__ge__", context.new_rustfunc(tuple_ge));
|
||||
context.set_attr(
|
||||
&tuple_type,
|
||||
"__doc__",
|
||||
context.new_str(tuple_doc.to_string()),
|
||||
);
|
||||
context.set_attr(&tuple_type, "index", context.new_rustfunc(tuple_index));
|
||||
}
|
||||
Reference in new issue
Block a user