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

Function try_update_quantity_from_element

crates/vm/src/cformat.rs:209–224  ·  view source on GitHub ↗
(
    vm: &VirtualMachine,
    element: Option<&PyObject>,
)

Source from the content-addressed store, hash-verified

207}
208
209fn try_update_quantity_from_element(
210 vm: &VirtualMachine,
211 element: Option<&PyObject>,
212) -> PyResult<CFormatQuantity> {
213 match element {
214 Some(width_obj) => {
215 if let Some(i) = width_obj.downcast_ref::<PyInt>() {
216 let i = i.try_to_primitive::<i32>(vm)?.unsigned_abs();
217 Ok(CFormatQuantity::Amount(i as usize))
218 } else {
219 Err(vm.new_type_error("* wants int"))
220 }
221 }
222 None => Err(vm.new_type_error("not enough arguments for format string")),
223 }
224}
225
226fn try_conversion_flag_from_tuple(
227 vm: &VirtualMachine,

Callers 2

Calls 1

ErrClass · 0.50

Tested by

no test coverage detected