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

Method try_from_borrowed_object

crates/stdlib/src/resource.rs:138–147  ·  view source on GitHub ↗
(vm: &VirtualMachine, obj: &'a PyObject)

Source from the content-addressed store, hash-verified

136 struct Limits(libc::rlimit);
137 impl<'a> TryFromBorrowedObject<'a> for Limits {
138 fn try_from_borrowed_object(vm: &VirtualMachine, obj: &'a PyObject) -> PyResult<Self> {
139 let seq: Vec<libc::rlim_t> = obj.try_to_value(vm)?;
140 match *seq {
141 [cur, max] => Ok(Self(libc::rlimit {
142 rlim_cur: cur & RLIM_INFINITY,
143 rlim_max: max & RLIM_INFINITY,
144 })),
145 _ => Err(vm.new_value_error("expected a tuple of 2 integers")),
146 }
147 }
148 }
149 impl ToPyObject for Limits {
150 fn to_pyobject(self, vm: &VirtualMachine) -> PyObjectRef {

Callers

nothing calls this directly

Calls 3

SelfFunction · 0.85
try_to_valueMethod · 0.80
ErrClass · 0.50

Tested by

no test coverage detected