mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
complex type: Added __doc__
This commit is contained in:
@@ -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__",
|
||||
|
||||
Reference in New Issue
Block a user