MCPcopy Index your code
hub / github.com/RustPython/RustPython / repr

Method repr

crates/vm/src/builtins/dict.rs:591–610  ·  view source on GitHub ↗
(zelf: &Py<Self>, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

589impl Representable for PyDict {
590 #[inline]
591 fn repr(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<PyStrRef> {
592 let s = if let Some(_guard) = ReprGuard::enter(vm, zelf.as_object()) {
593 let mut result = Wtf8Buf::from("{");
594 let mut first = true;
595 for (key, value) in zelf {
596 if !first {
597 result.push_str(", ");
598 }
599 first = false;
600 result.push_wtf8(key.repr(vm)?.as_wtf8());
601 result.push_str(": ");
602 result.push_wtf8(value.repr(vm)?.as_wtf8());
603 }
604 result.push_char('}');
605 vm.ctx.new_str(result)
606 } else {
607 vm.ctx.intern_str("{...}").to_owned()
608 };
609 Ok(s)
610 }
611
612 #[cold]
613 fn repr_str(_zelf: &Py<Self>, _vm: &VirtualMachine) -> PyResult<String> {

Callers

nothing calls this directly

Calls 8

push_wtf8Method · 0.80
intern_strMethod · 0.80
as_objectMethod · 0.45
push_strMethod · 0.45
as_wtf8Method · 0.45
push_charMethod · 0.45
new_strMethod · 0.45
to_ownedMethod · 0.45

Tested by

no test coverage detected