Skip to content

Commit

Permalink
Make EcoVec::extend_from_trusted public
Browse files Browse the repository at this point in the history
Add the bound `I::IntoIter: ExactSizeIterator` to try to prevent unsafe usage.
  • Loading branch information
Kai Schmidt committed Mar 12, 2024
1 parent bb20e5d commit 47c8d55
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,10 +686,12 @@ impl<T> EcoVec<T> {
impl<T: Clone> EcoVec<T> {
/// Clones and pushes all elements in a trusted-len iterator to the vector.
///
/// # Safety
/// The iterator must produce exactly `count` items.
unsafe fn extend_from_trusted<I>(&mut self, count: usize, iter: I)
pub unsafe fn extend_from_trusted<I>(&mut self, count: usize, iter: I)
where
I: IntoIterator<Item = T>,
I::IntoIter: ExactSizeIterator,
{
if count == 0 {
return;
Expand Down

0 comments on commit 47c8d55

Please sign in to comment.