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

Method from_tuple

crates/stdlib/src/socket.rs:2526–2534  ·  view source on GitHub ↗
(tuple: &[PyObjectRef], vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

2524
2525 impl Address {
2526 fn from_tuple(tuple: &[PyObjectRef], vm: &VirtualMachine) -> PyResult<Self> {
2527 let host = PyStrRef::try_from_object(vm, tuple[0].clone())?;
2528 let host = host.try_into_utf8(vm)?;
2529 let port = i32::try_from_borrowed_object(vm, &tuple[1])?;
2530 let port = port
2531 .to_u16()
2532 .ok_or_else(|| vm.new_overflow_error("port must be 0-65535."))?;
2533 Ok(Self { host, port })
2534 }
2535
2536 fn from_tuple_ipv6(
2537 tuple: &[PyObjectRef],

Callers

nothing calls this directly

Calls 3

try_into_utf8Method · 0.80
ok_or_elseMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected