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

Function check_matched

crates/vm/src/warn.rs:102–111  ·  view source on GitHub ↗

None matches everything; plain strings do exact comparison; regex objects use .match().

(obj: &PyObject, arg: &PyObject, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

100/// None matches everything; plain strings do exact comparison;
101/// regex objects use .match().
102fn check_matched(obj: &PyObject, arg: &PyObject, vm: &VirtualMachine) -> PyResult<bool> {
103 if vm.is_none(obj) {
104 return Ok(true);
105 }
106 if obj.class().is(vm.ctx.types.str_type) {
107 return obj.rich_compare_bool(arg, crate::types::PyComparisonOp::Eq, vm);
108 }
109 let result = vm.call_method(obj, "match", (arg.to_owned(),))?;
110 result.is_true(vm)
111}
112
113fn get_warnings_attr(
114 vm: &VirtualMachine,

Callers 1

get_filterFunction · 0.85

Calls 7

isMethod · 0.80
rich_compare_boolMethod · 0.80
is_trueMethod · 0.80
is_noneMethod · 0.45
classMethod · 0.45
call_methodMethod · 0.45
to_ownedMethod · 0.45

Tested by

no test coverage detected