From 25dad16e32c50c8e61b681903937656dbf8929a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20W=C3=BClker?= Date: Thu, 21 Sep 2023 09:53:17 +0200 Subject: [PATCH] sl-std: Extend SubsliceOffset to return full range --- sl-std/src/slice.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sl-std/src/slice.rs b/sl-std/src/slice.rs index 4a0db4c8..0231d750 100644 --- a/sl-std/src/slice.rs +++ b/sl-std/src/slice.rs @@ -22,7 +22,7 @@ impl SubsliceOffset for str { fn subslice_offset(&self, inner: &str) -> Option { let outer = self.as_ptr() as usize; let inner = inner.as_ptr() as usize; - if (outer..outer + self.len()).contains(&inner) { + if (outer..=outer + self.len()).contains(&inner) { Some(inner.wrapping_sub(outer)) } else { None @@ -34,7 +34,7 @@ impl SubsliceOffset for str { let outer = self.as_ptr() as usize; let end = start + inner.len(); - if !(outer..outer + self.len()).contains(&end) { + if outer + self.len() < end { return None; }