mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +08:00
Implement no-arg dict builtin
This commit is contained in:
1 parent
99ccc97907
commit
78447bb4f4
2 files changed
+9
-1
No files matched your search
@@ -0,0 +1 @@
|
||||
assert len(dict()) == 0
|
||||
+8
-1
@@ -69,7 +69,13 @@ fn builtin_compile(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
|
||||
// builtin_complex
|
||||
// builtin_delattr
|
||||
// builtin_dict
|
||||
|
||||
fn builtin_dict(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
if !args.args.is_empty() {
|
||||
unimplemented!("only zero-arg version of dict is currently supported")
|
||||
}
|
||||
Ok(vm.new_dict())
|
||||
}
|
||||
|
||||
fn builtin_dir(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
if args.args.is_empty() {
|
||||
@@ -237,6 +243,7 @@ pub fn make_module(ctx: &PyContext) -> PyObjectRef {
|
||||
dict.insert(String::from("all"), ctx.new_rustfunc(builtin_all));
|
||||
dict.insert(String::from("any"), ctx.new_rustfunc(builtin_any));
|
||||
dict.insert(String::from("compile"), ctx.new_rustfunc(builtin_compile));
|
||||
dict.insert(String::from("dict"), ctx.new_rustfunc(builtin_dict));
|
||||
dict.insert(String::from("dir"), ctx.new_rustfunc(builtin_dir));
|
||||
dict.insert(String::from("eval"), ctx.new_rustfunc(builtin_eval));
|
||||
dict.insert(String::from("id"), ctx.new_rustfunc(builtin_id));
|
||||
|
||||
Reference in new issue
Block a user