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

Method __str__

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

Source from the content-addressed store, hash-verified

1483
1484 #[pymethod]
1485 fn __str__(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<PyStrRef> {
1486 if zelf.class().is(vm.ctx.types.str_type) {
1487 // Already exact str, just return a reference
1488 Ok(zelf.to_owned())
1489 } else {
1490 // Subclass, create a new exact str
1491 Ok(PyStr::from(zelf.data.clone()).into_ref(&vm.ctx))
1492 }
1493 }
1494}
1495
1496impl PyRef<PyStr> {

Callers

nothing calls this directly

Calls 5

isMethod · 0.80
classMethod · 0.45
to_ownedMethod · 0.45
into_refMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected