Skip to content

Commit d74ba50

Browse files
committed
Delete PrtValueIter
1 parent 7c24902 commit d74ba50

2 files changed

Lines changed: 2 additions & 47 deletions

File tree

‎docs/src/runtime/iterators.md‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff 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

‎libcc2rs/src/rc.rs‎

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff 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-
12691232
impl<T> Sub for Ptr<T> {
12701233
type Output = isize;
12711234
fn sub(self, other: Self) -> Self::Output {

0 commit comments

Comments
 (0)