about summary refs log tree commit diff
path: root/library/alloc/src/vec
diff options
context:
space:
mode:
authorTomasz Miąsko <tomasz.miasko@gmail.com>2021-02-12 00:00:00 +0000
committerTomasz Miąsko <tomasz.miasko@gmail.com>2021-02-15 17:36:29 +0100
commitdc3304c341ff4f5551cc0f7960f4e56521effd3d (patch)
treee31168ca012cb157f759890e57a17f8d5d228a2f /library/alloc/src/vec
parent9503ea19edbf01b9435e80e17d60ce1b88390116 (diff)
downloadrust-dc3304c341ff4f5551cc0f7960f4e56521effd3d.tar.gz
rust-dc3304c341ff4f5551cc0f7960f4e56521effd3d.zip
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.
Diffstat (limited to 'library/alloc/src/vec')
-rw-r--r--library/alloc/src/vec/into_iter.rs4
1 files changed, 1 insertions, 3 deletions
diff --git a/library/alloc/src/vec/into_iter.rs b/library/alloc/src/vec/into_iter.rs
index f131d06bb18..bcbdffabc7f 100644
--- a/library/alloc/src/vec/into_iter.rs
+++ b/library/alloc/src/vec/into_iter.rs
@@ -212,9 +212,7 @@ unsafe impl<T, A: Allocator> TrustedRandomAccess for IntoIter<T, A>
 where
     T: Copy,
 {
-    fn may_have_side_effect() -> bool {
-        false
-    }
+    const MAY_HAVE_SIDE_EFFECT: bool = false;
 }
 
 #[stable(feature = "vec_into_iter_clone", since = "1.8.0")]