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

Function try_conversion_flag_from_tuple

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

Source from the content-addressed store, hash-verified

224}
225
226fn try_conversion_flag_from_tuple(
227 vm: &VirtualMachine,
228 element: Option<&PyObject>,
229) -> PyResult<CConversionFlags> {
230 match element {
231 Some(width_obj) => {
232 if let Some(i) = width_obj.downcast_ref::<PyInt>() {
233 let i = i.try_to_primitive::<i32>(vm)?;
234 let flags = if i < 0 {
235 CConversionFlags::LEFT_ADJUST
236 } else {
237 CConversionFlags::from_bits(0).unwrap()
238 };
239 Ok(flags)
240 } else {
241 Err(vm.new_type_error("* wants int"))
242 }
243 }
244 None => Err(vm.new_type_error("not enough arguments for format string")),
245 }
246}
247
248fn try_update_quantity_from_tuple<'a, I: Iterator<Item = &'a PyObjectRef>>(
249 vm: &VirtualMachine,

Callers 1

Calls 2

ErrClass · 0.50
unwrapMethod · 0.45

Tested by

no test coverage detected