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

Method startswith

crates/vm/src/builtins/bytearray.rs:384–402  ·  view source on GitHub ↗
(
        &self,
        options: anystr::StartsEndsWithArgs,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

382
383 #[pymethod]
384 fn startswith(
385 &self,
386 options: anystr::StartsEndsWithArgs,
387 vm: &VirtualMachine,
388 ) -> PyResult<bool> {
389 let borrowed = self.borrow_buf();
390 let (affix, substr) =
391 match options.prepare(&*borrowed, borrowed.len(), |s, r| s.get_bytes(r)) {
392 Some(x) => x,
393 None => return Ok(false),
394 };
395 substr.py_starts_ends_with(
396 &affix,
397 "startswith",
398 "bytes",
399 |s, x: PyBytesInner| s.starts_with(x.as_bytes()),
400 vm,
401 )
402 }
403
404 #[pymethod]
405 fn find(&self, options: ByteInnerFindOptions, vm: &VirtualMachine) -> PyResult<isize> {

Callers

nothing calls this directly

Calls 7

py_starts_ends_withMethod · 0.80
starts_withMethod · 0.80
borrow_bufMethod · 0.45
prepareMethod · 0.45
lenMethod · 0.45
get_bytesMethod · 0.45
as_bytesMethod · 0.45

Tested by

no test coverage detected