mirror of
https://github.com/danog/ext-php-rs.git
synced 2024-11-30 04:39:04 +01:00
Cleanup
This commit is contained in:
parent
0f401865f7
commit
f449f4e4e1
@ -20,7 +20,7 @@ that implements the `Traversable` interface. This means that any value that can
|
||||
#[php_function]
|
||||
pub fn test_iterable(mut iterable: Iterable) {
|
||||
for (k, v) in iterable.iter().expect("cannot rewind iterator") {
|
||||
println!("k: {:?} v: {}", k, v.string().unwrap());
|
||||
println!("k: {} v: {}", k.string().unwrap(), v.string().unwrap());
|
||||
}
|
||||
}
|
||||
# fn main() {}
|
||||
@ -34,14 +34,11 @@ pub fn test_iterable(mut iterable: Iterable) {
|
||||
$generator = function() {
|
||||
yield 'hello' => 'world';
|
||||
yield 'rust' => 'php';
|
||||
yield 'okk';
|
||||
yield new class {} => new class {};
|
||||
};
|
||||
|
||||
$array = [
|
||||
'hello' => 'world',
|
||||
'rust' => 'php',
|
||||
'okk',
|
||||
];
|
||||
|
||||
test_iterable($generator());
|
||||
@ -53,8 +50,6 @@ Output:
|
||||
```text
|
||||
k: hello v: world
|
||||
k: rust v: php
|
||||
k: 0 v: okk
|
||||
k: hello v: world
|
||||
k: rust v: php
|
||||
k: 0 v: okk
|
||||
```
|
||||
|
@ -23,7 +23,9 @@ If you want a more universal `iterable` type that also supports arrays, see [Ite
|
||||
#[php_function]
|
||||
pub fn test_iterator(iterator: &mut ZendIterator) {
|
||||
for (k, v) in iterator.iter().expect("cannot rewind iterator") {
|
||||
println!("k: {:?} v: {}", k, v.string().unwrap());
|
||||
// Note that the key can be anything, even an object
|
||||
// when iterating over Traversables!
|
||||
println!("k: {} v: {}", k.string().unwrap(), v.string().unwrap());
|
||||
}
|
||||
}
|
||||
# fn main() {}
|
||||
@ -37,8 +39,6 @@ pub fn test_iterator(iterator: &mut ZendIterator) {
|
||||
$generator = function() {
|
||||
yield 'hello' => 'world';
|
||||
yield 'rust' => 'php';
|
||||
yield 'okk';
|
||||
yield new class {} => new class {};
|
||||
};
|
||||
|
||||
test_iterator($generator());
|
||||
@ -49,5 +49,4 @@ Output:
|
||||
```text
|
||||
k: hello v: world
|
||||
k: rust v: php
|
||||
k: 0 v: okk
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user