Make SpecInPlaceCollect
use TrustedRandomAccessNoCoerce
This commit is contained in:
parent
9ff421da99
commit
89583e98e8
2 changed files with 7 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
||||||
use core::iter::{InPlaceIterable, SourceIter, TrustedRandomAccess};
|
use core::iter::{InPlaceIterable, SourceIter, TrustedRandomAccessNoCoerce};
|
||||||
use core::mem::{self, ManuallyDrop};
|
use core::mem::{self, ManuallyDrop};
|
||||||
use core::ptr::{self};
|
use core::ptr::{self};
|
||||||
|
|
||||||
|
@ -101,6 +101,8 @@ fn write_in_place_with_drop<T>(
|
||||||
trait SpecInPlaceCollect<T, I>: Iterator<Item = T> {
|
trait SpecInPlaceCollect<T, I>: Iterator<Item = T> {
|
||||||
/// Collects an iterator (`self`) into the destination buffer (`dst`) and returns the number of items
|
/// Collects an iterator (`self`) into the destination buffer (`dst`) and returns the number of items
|
||||||
/// collected. `end` is the last writable element of the allocation and used for bounds checks.
|
/// collected. `end` is the last writable element of the allocation and used for bounds checks.
|
||||||
|
// FIXME: Clarify safety conditions. Iterator must not be coerced to a subtype
|
||||||
|
// after this call due to potential use of [`TrustedRandomAccessNoCoerce`].
|
||||||
fn collect_in_place(&mut self, dst: *mut T, end: *const T) -> usize;
|
fn collect_in_place(&mut self, dst: *mut T, end: *const T) -> usize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +126,7 @@ where
|
||||||
|
|
||||||
impl<T, I> SpecInPlaceCollect<T, I> for I
|
impl<T, I> SpecInPlaceCollect<T, I> for I
|
||||||
where
|
where
|
||||||
I: Iterator<Item = T> + TrustedRandomAccess,
|
I: Iterator<Item = T> + TrustedRandomAccessNoCoerce,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn collect_in_place(&mut self, dst_buf: *mut T, end: *const T) -> usize {
|
fn collect_in_place(&mut self, dst_buf: *mut T, end: *const T) -> usize {
|
||||||
|
|
|
@ -514,6 +514,9 @@ impl<A: Debug + TrustedRandomAccessNoCoerce, B: Debug + TrustedRandomAccessNoCoe
|
||||||
/// `self.__iterator_get_unchecked(idx)`, assuming that the required traits are implemented.
|
/// `self.__iterator_get_unchecked(idx)`, assuming that the required traits are implemented.
|
||||||
/// * It must also be safe to drop `self` after calling `self.__iterator_get_unchecked(idx)`.
|
/// * It must also be safe to drop `self` after calling `self.__iterator_get_unchecked(idx)`.
|
||||||
/// * If `T` is a subtype of `Self`, then it must be safe to coerce `self` to `T`.
|
/// * If `T` is a subtype of `Self`, then it must be safe to coerce `self` to `T`.
|
||||||
|
//
|
||||||
|
// FIXME: Clarify interaction with SourceIter/InPlaceIterable. Calling `SouceIter::as_inner`
|
||||||
|
// after `__iterator_get_unchecked` is supposed to be allowed.
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[unstable(feature = "trusted_random_access", issue = "none")]
|
#[unstable(feature = "trusted_random_access", issue = "none")]
|
||||||
#[rustc_specialization_trait]
|
#[rustc_specialization_trait]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue