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

Method try_into_from_object

crates/stdlib/src/array.rs:561–568  ·  view source on GitHub ↗
(vm: &VirtualMachine, obj: PyObjectRef)

Source from the content-addressed store, hash-verified

559
560 impl ArrayElement for WideChar {
561 fn try_into_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self> {
562 PyUtf8StrRef::try_from_object(vm, obj)?
563 .as_str()
564 .chars()
565 .exactly_one()
566 .map(|ch| Self(ch as _))
567 .map_err(|_| vm.new_type_error("array item must be unicode character"))
568 }
569 fn byteswap(self) -> Self {
570 Self(self.0.swap_bytes())
571 }

Callers

nothing calls this directly

Calls 4

SelfFunction · 0.85
charsMethod · 0.80
mapMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected