Skip to content

Commit da9db12

Browse files
kakserpomXenira
andauthored
feat(zval): add Zval::null()
* feat(zval): null() * test(zval): add unit test for `Zval::null()` Refs: #521 Co-authored-by: Xenira <[email protected]>
1 parent 2a0d615 commit da9db12

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/types/zval.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ impl Zval {
5454
}
5555
}
5656

57+
/// Creates a null zval
58+
#[must_use]
59+
pub fn null() -> Zval {
60+
let mut zval = Zval::new();
61+
zval.set_null();
62+
zval
63+
}
64+
5765
/// Dereference the zval, if it is a reference.
5866
#[must_use]
5967
pub fn dereference(&self) -> &Self {
@@ -790,3 +798,18 @@ impl<'a> FromZvalMut<'a> for &'a mut Zval {
790798
Some(zval)
791799
}
792800
}
801+
802+
#[cfg(test)]
803+
#[cfg(feature = "embed")]
804+
mod tests {
805+
use super::*;
806+
use crate::embed::Embed;
807+
808+
#[test]
809+
fn test_zval_null() {
810+
Embed::run(|| {
811+
let zval = Zval::null();
812+
assert!(zval.is_null());
813+
});
814+
}
815+
}

0 commit comments

Comments
 (0)