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

Method validate_downcastable_from

crates/vm/src/builtins/str.rs:2034–2038  ·  view source on GitHub ↗
(obj: &PyObject)

Source from the content-addressed store, hash-verified

2032 const PAYLOAD_TYPE_ID: core::any::TypeId = core::any::TypeId::of::<PyStr>();
2033
2034 unsafe fn validate_downcastable_from(obj: &PyObject) -> bool {
2035 // SAFETY: we know the object is a PyStr in this context
2036 let wtf8 = unsafe { obj.downcast_unchecked_ref::<PyStr>() };
2037 wtf8.is_utf8()
2038 }
2039
2040 fn try_downcast_from(obj: &PyObject, vm: &VirtualMachine) -> PyResult<()> {
2041 let str = obj.try_downcast_ref::<PyStr>(vm)?;

Callers

nothing calls this directly

Calls 1

is_utf8Method · 0.45

Tested by

no test coverage detected