Skip to content

Commit

Permalink
Merge pull request #298 from davidcole1340/rm_double_type_coercion
Browse files Browse the repository at this point in the history
Remove type coercion
  • Loading branch information
danog authored Nov 28, 2023
2 parents f87734e + 9b56722 commit 950ea62
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repository = "https://github.com/davidcole1340/ext-php-rs"
homepage = "https://github.com/davidcole1340/ext-php-rs"
license = "MIT OR Apache-2.0"
keywords = ["php", "ffi", "zend"]
version = "0.11.2"
version = "0.12.0"
authors = ["David Cole <[email protected]>"]
edition = "2018"
categories = ["api-bindings"]
Expand Down
9 changes: 1 addition & 8 deletions src/types/zval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl Zval {
if self.is_double() {
Some(unsafe { self.value.dval })
} else {
self.long().map(|x| x as f64)
None
}
}

Expand All @@ -114,17 +114,10 @@ impl Zval {

/// Returns the value of the zval if it is a string.
///
/// If the zval does not contain a string, the function will check if it
/// contains a double or a long, and if so it will convert the value to
/// a [`String`] and return it. Don't rely on this logic, as there is
/// potential for this to change to match the output of the [`str()`]
/// function.
///
/// [`str()`]: #method.str
pub fn string(&self) -> Option<String> {
self.str()
.map(|s| s.to_string())
.or_else(|| self.double().map(|x| x.to_string()))
}

/// Returns the value of the zval if it is a string.
Expand Down

0 comments on commit 950ea62

Please sign in to comment.