File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,17 +27,9 @@ for x in v.as_pointer() as Ptr<i32> {
2727}
2828```
2929
30- Two variants serve special cases . ` StringIterator ` , returned by
30+ One variant serves a special case . ` StringIterator ` , returned by
3131` to_string_iterator ` , stops before the trailing zero byte, so iterating a
32- ` std::string ` visits its characters only. ` PtrValueIter ` yields copies of the
33- elements instead of pointers to them; rule bodies use it to feed a range of C
34- memory to Rust iterator adaptors:
35-
36- ``` rust
37- // std::accumulate(first, last, init)
38- let count = (last - first ) as usize ;
39- PtrValueIter :: new (& first , count ). fold (init , | acc , x | acc + x )
40- ```
32+ ` std::string ` visits its characters only.
4133
4234## Stable iterators
4335
Original file line number Diff line number Diff line change @@ -1229,43 +1229,6 @@ impl<T> Iterator for Ptr<T> {
12291229 }
12301230}
12311231
1232- // Ptr iterator that yields values instead of pointers.
1233- // It's more efficient and it's useful to implement idiomatic iterator patterns
1234- pub struct PtrValueIter < T > {
1235- ptr : Ptr < T > ,
1236- n : usize ,
1237- }
1238-
1239- impl < T > PtrValueIter < T > {
1240- pub fn new ( ptr : & Ptr < T > , n : usize ) -> Self {
1241- Self {
1242- ptr : ptr. clone ( ) ,
1243- n,
1244- }
1245- }
1246- }
1247-
1248- impl < T : Clone + ByteRepr > Iterator for PtrValueIter < T > {
1249- type Item = T ;
1250-
1251- fn next ( & mut self ) -> Option < Self :: Item > {
1252- if self . n > 0 {
1253- let value = self . ptr . read ( ) ;
1254- self . ptr += 1 ;
1255- self . n -= 1 ;
1256- Some ( value)
1257- } else {
1258- None
1259- }
1260- }
1261-
1262- fn size_hint ( & self ) -> ( usize , Option < usize > ) {
1263- ( self . n , Some ( self . n ) )
1264- }
1265- }
1266-
1267- impl < T : Clone + ByteRepr > ExactSizeIterator for PtrValueIter < T > { }
1268-
12691232impl < T > Sub for Ptr < T > {
12701233 type Output = isize ;
12711234 fn sub ( self , other : Self ) -> Self :: Output {
You can’t perform that action at this time.
0 commit comments