MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / subslice_range

Function subslice_range

crates/wasmtime/src/runtime/code_memory.rs:702–712  ·  view source on GitHub ↗

Returns the range of `inner` within `outer`, such that `outer[range]` is the same as `inner`. This method requires that `inner` is a sub-slice of `outer`, and if that isn't true then this method will panic.

(inner: &[u8], outer: &[u8])

Source from the content-addressed store, hash-verified

700/// This method requires that `inner` is a sub-slice of `outer`, and if that
701/// isn't true then this method will panic.
702fn subslice_range(inner: &[u8], outer: &[u8]) -> Range<usize> {
703 if inner.len() == 0 {
704 return 0..0;
705 }
706
707 assert!(outer.as_ptr() <= inner.as_ptr());
708 assert!((&inner[inner.len() - 1] as *const _) <= (&outer[outer.len() - 1] as *const _));
709
710 let start = inner.as_ptr() as usize - outer.as_ptr() as usize;
711 start..start + inner.len()
712}

Callers 1

newMethod · 0.85

Calls 2

lenMethod · 0.45
as_ptrMethod · 0.45

Tested by

no test coverage detected