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])
| 700 | /// This method requires that `inner` is a sub-slice of `outer`, and if that |
| 701 | /// isn't true then this method will panic. |
| 702 | fn 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 | } |