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

Method startswith

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

Source from the content-addressed store, hash-verified

372
373 #[pymethod]
374 fn startswith(
375 &self,
376 options: anystr::StartsEndsWithArgs,
377 vm: &VirtualMachine,
378 ) -> PyResult<bool> {
379 let (affix, substr) =
380 match options.prepare(self.as_bytes(), self.len(), |s, r| s.get_bytes(r)) {
381 Some(x) => x,
382 None => return Ok(false),
383 };
384 substr.py_starts_ends_with(
385 &affix,
386 "startswith",
387 "bytes",
388 |s, x: PyBytesInner| s.starts_with(x.as_bytes()),
389 vm,
390 )
391 }
392
393 #[pymethod]
394 fn find(&self, options: ByteInnerFindOptions, vm: &VirtualMachine) -> PyResult<isize> {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected