From 30e700403555c93e96a24aaed5dc27821b20d734 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Tue, 28 Nov 2023 10:52:25 +0100 Subject: [PATCH 1/2] Pub ArrayKey and update example Currently it's not possible to match against the array key, as it's not exported from mod.rs it seems. --- src/types/array.rs | 12 +++++++----- src/types/mod.rs | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/types/array.rs b/src/types/array.rs index 19768f3..34156d8 100644 --- a/src/types/array.rs +++ b/src/types/array.rs @@ -519,15 +519,17 @@ impl ZendHashTable { /// # Example /// /// ```no_run - /// use ext_php_rs::types::ZendHashTable; + /// use ext_php_rs::types::{ZendHashTable, ArrayKey}; /// /// let mut ht = ZendHashTable::new(); /// /// for (key, val) in ht.iter() { - /// // ^ Index if inserted at an index. - /// // ^ Optional string key, if inserted like a hashtable. - /// // ^ Inserted value. - /// + /// match key { + /// ArrayKey::Long(index) => { + /// } + /// ArrayKey::String(key) => { + /// } + /// } /// dbg!(key, val); /// } #[inline] diff --git a/src/types/mod.rs b/src/types/mod.rs index 846c8d1..51e5fa7 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -13,7 +13,7 @@ mod object; mod string; mod zval; -pub use array::ZendHashTable; +pub use array::{ZendHashTable, ArrayKey}; pub use callable::ZendCallable; pub use class_object::ZendClassObject; pub use iterable::Iterable; From 8c4a7ae06c788d32587f97acde21f0588f51f7b1 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Tue, 28 Nov 2023 10:56:51 +0100 Subject: [PATCH 2/2] fmt --- src/types/array.rs | 2 +- src/types/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types/array.rs b/src/types/array.rs index 34156d8..0b54f6e 100644 --- a/src/types/array.rs +++ b/src/types/array.rs @@ -524,7 +524,7 @@ impl ZendHashTable { /// let mut ht = ZendHashTable::new(); /// /// for (key, val) in ht.iter() { - /// match key { + /// match &key { /// ArrayKey::Long(index) => { /// } /// ArrayKey::String(key) => { diff --git a/src/types/mod.rs b/src/types/mod.rs index 51e5fa7..a3db468 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -13,7 +13,7 @@ mod object; mod string; mod zval; -pub use array::{ZendHashTable, ArrayKey}; +pub use array::{ArrayKey, ZendHashTable}; pub use callable::ZendCallable; pub use class_object::ZendClassObject; pub use iterable::Iterable;