From c103c284b93039149f0ec2a4f3d20ca89f34c0ad Mon Sep 17 00:00:00 2001 From: Phoebe Bell Date: Thu, 16 Jan 2020 18:38:04 -0800 Subject: [PATCH] Move comments for tidy --- src/libcore/str/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index ec1713d1d4b..3bfeee87cc0 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -1301,9 +1301,9 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { impl<'a, P: Pattern<'a>> MatchIndicesInternal<'a, P> { #[inline] fn next(&mut self) -> Option<(usize, &'a str)> { - // SAFETY: `Searcher` guarantees that `start` and `end` lie on unicode boundaries. self.0 .next_match() + // SAFETY: `Searcher` guarantees that `start` and `end` lie on unicode boundaries. .map(|(start, end)| unsafe { (start, self.0.haystack().get_unchecked(start..end)) }) } @@ -1312,9 +1312,9 @@ fn next_back(&mut self) -> Option<(usize, &'a str)> where P::Searcher: ReverseSearcher<'a>, { - // SAFETY: `Searcher` guarantees that `start` and `end` lie on unicode boundaries. self.0 .next_match_back() + // SAFETY: `Searcher` guarantees that `start` and `end` lie on unicode boundaries. .map(|(start, end)| unsafe { (start, self.0.haystack().get_unchecked(start..end)) }) } } @@ -3901,8 +3901,8 @@ pub fn strip_prefix<'a, P: Pattern<'a>>(&'a self, prefix: P) -> Option<&'a str> "The first search step from Searcher \ must include the first character" ); + // SAFETY: `Searcher` is known to return valid indices. unsafe { - // Searcher is known to return valid indices. Some(self.get_unchecked(len..)) } } else { @@ -3942,8 +3942,8 @@ pub fn strip_suffix<'a, P>(&'a self, suffix: P) -> Option<&'a str> "The first search step from ReverseSearcher \ must include the last character" ); + // SAFETY: `Searcher` is known to return valid indices. unsafe { - // Searcher is known to return valid indices. Some(self.get_unchecked(..start)) } } else { @@ -4381,8 +4381,8 @@ fn default() -> Self { #[stable(feature = "default_mut_str", since = "1.28.0")] impl Default for &mut str { /// Creates an empty mutable str - // SAFETY: `str` is guranteed to be UTF-8. fn default() -> Self { + // SAFETY: The empty string is valid UTF-8. unsafe { from_utf8_unchecked_mut(&mut []) } } } -- 2.44.0