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

Function try_as_bytes

crates/vm/src/bytes_inner.rs:975–984  ·  view source on GitHub ↗
(obj: PyObjectRef, f: F)

Source from the content-addressed store, hash-verified

973}
974
975pub fn try_as_bytes<F, R>(obj: PyObjectRef, f: F) -> Option<R>
976where
977 F: Fn(&[u8]) -> R,
978{
979 match_class!(match obj {
980 i @ PyBytes => Some(f(i.as_bytes())),
981 j @ PyByteArray => Some(f(&j.borrow_buf())),
982 _ => None,
983 })
984}
985
986#[inline]
987fn count_substring(haystack: &[u8], needle: &[u8], max_count: Option<usize>) -> usize {

Callers 1

get_valueMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected