Auto merge of #82043 - tmiasko:may-have-side-effect, r=kennytm

Turn may_have_side_effect into an associated constant

The `may_have_side_effect` is an implementation detail of `TrustedRandomAccess`
trait. It describes if obtaining an iterator element may have side effects. It
is currently implemented as an associated function.

Turn `may_have_side_effect` into an associated constant. This makes the
value immediately available to the optimizer.
This commit is contained in:
bors
2021-03-02 16:08:32 +00:00
9 changed files with 30 additions and 78 deletions

View File

@@ -321,10 +321,7 @@ unsafe impl TrustedLen for Bytes<'_> {}
#[doc(hidden)]
#[unstable(feature = "trusted_random_access", issue = "none")]
unsafe impl TrustedRandomAccess for Bytes<'_> {
#[inline]
fn may_have_side_effect() -> bool {
false
}
const MAY_HAVE_SIDE_EFFECT: bool = false;
}
/// This macro generates a Clone impl for string pattern API