File tree Expand file tree Collapse file tree 2 files changed +4
-3
lines changed
branches/stable/src/libcollections Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,6 @@ refs/heads/tmp: e5d90d98402475b6e154ce216f9efcb80da1a747
29
29
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
30
30
refs/tags/homu-tmp: 1fe32ca12c51afcd761d9962f51a74ff0d07a591
31
31
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32
- refs/heads/stable: 07a9c5353320c22596241dd0699f209b4567fc2f
32
+ refs/heads/stable: 8d26dedecb16cc97a1d9897ce7afc99de63e7815
33
33
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
34
34
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
Original file line number Diff line number Diff line change @@ -1482,7 +1482,7 @@ impl<T> FromIterator<T> for Vec<T> {
1482
1482
None => return Vec :: new ( ) ,
1483
1483
Some ( element) => {
1484
1484
let ( lower, _) = iterator. size_hint ( ) ;
1485
- let mut vector = Vec :: with_capacity ( 1 + lower) ;
1485
+ let mut vector = Vec :: with_capacity ( lower. saturating_add ( 1 ) ) ;
1486
1486
unsafe {
1487
1487
ptr:: write ( vector. get_unchecked_mut ( 0 ) , element) ;
1488
1488
vector. set_len ( 1 ) ;
@@ -1570,10 +1570,11 @@ impl<T> Vec<T> {
1570
1570
let len = self . len ( ) ;
1571
1571
if len == self . capacity ( ) {
1572
1572
let ( lower, _) = iterator. size_hint ( ) ;
1573
- self . reserve ( lower + 1 ) ;
1573
+ self . reserve ( lower. saturating_add ( 1 ) ) ;
1574
1574
}
1575
1575
unsafe {
1576
1576
ptr:: write ( self . get_unchecked_mut ( len) , element) ;
1577
+ // NB can't overflow since we would have had to alloc the address space
1577
1578
self . set_len ( len + 1 ) ;
1578
1579
}
1579
1580
}
You can’t perform that action at this time.
0 commit comments