Skip to content

Commit f449f4e

Browse files
committed
Cleanup
1 parent 0f40186 commit f449f4e

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

guide/src/types/iterable.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ that implements the `Traversable` interface. This means that any value that can
2020
#[php_function]
2121
pub fn test_iterable(mut iterable: Iterable) {
2222
for (k, v) in iterable.iter().expect("cannot rewind iterator") {
23-
println!("k: {:?} v: {}", k, v.string().unwrap());
23+
println!("k: {} v: {}", k.string().unwrap(), v.string().unwrap());
2424
}
2525
}
2626
# fn main() {}
@@ -34,14 +34,11 @@ pub fn test_iterable(mut iterable: Iterable) {
3434
$generator = function() {
3535
yield 'hello' => 'world';
3636
yield 'rust' => 'php';
37-
yield 'okk';
38-
yield new class {} => new class {};
3937
};
4038

4139
$array = [
4240
'hello' => 'world',
4341
'rust' => 'php',
44-
'okk',
4542
];
4643

4744
test_iterable($generator());
@@ -53,8 +50,6 @@ Output:
5350
```text
5451
k: hello v: world
5552
k: rust v: php
56-
k: 0 v: okk
5753
k: hello v: world
5854
k: rust v: php
59-
k: 0 v: okk
6055
```

guide/src/types/iterator.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ If you want a more universal `iterable` type that also supports arrays, see [Ite
2323
#[php_function]
2424
pub fn test_iterator(iterator: &mut ZendIterator) {
2525
for (k, v) in iterator.iter().expect("cannot rewind iterator") {
26-
println!("k: {:?} v: {}", k, v.string().unwrap());
26+
// Note that the key can be anything, even an object
27+
// when iterating over Traversables!
28+
println!("k: {} v: {}", k.string().unwrap(), v.string().unwrap());
2729
}
2830
}
2931
# fn main() {}
@@ -37,8 +39,6 @@ pub fn test_iterator(iterator: &mut ZendIterator) {
3739
$generator = function() {
3840
yield 'hello' => 'world';
3941
yield 'rust' => 'php';
40-
yield 'okk';
41-
yield new class {} => new class {};
4242
};
4343

4444
test_iterator($generator());
@@ -49,5 +49,4 @@ Output:
4949
```text
5050
k: hello v: world
5151
k: rust v: php
52-
k: 0 v: okk
5352
```

0 commit comments

Comments
 (0)