complex type: Added __doc__

This commit is contained in:
ZapAnton
2019-02-08 18:47:23 +03:00
parent 07fd61f55f
commit 031f062e72

View File

@@ -8,8 +8,18 @@ use num_complex::Complex64;
pub fn init(context: &PyContext) {
let complex_type = &context.complex_type;
let complex_doc =
"Create a complex number from a real part and an optional imaginary part.\n\n\
This is equivalent to (real + imag*1j) where imag defaults to 0.";
context.set_attr(&complex_type, "__add__", context.new_rustfunc(complex_add));
context.set_attr(&complex_type, "__new__", context.new_rustfunc(complex_new));
context.set_attr(
&complex_type,
"__doc__",
context.new_str(complex_doc.to_string()),
);
context.set_attr(
&complex_type,
"__repr__",