Skip to content

Commit 68059bd

Browse files
committed
Fix mutable refs
1 parent 614f5b4 commit 68059bd

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

crates/macros/src/function.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -343,18 +343,12 @@ impl Arg {
343343
}
344344
Type::Reference(ref_) => {
345345
// Returning references is invalid, so let's just create our arg
346-
347-
// Change any `&mut T` into `&T` and set the `as_ref` attribute on the Arg
348-
// to marked it as a "passed by ref" PHP argument.
349-
let mut ref_ = ref_.clone();
350-
let is_mutable_ref = ref_.mutability.is_some();
351-
ref_.mutability = None;
352346
Some(Arg::new(
353347
name,
354348
ref_.to_token_stream().to_string(),
355349
false,
356350
default,
357-
is_mutable_ref,
351+
ref_.mutability.is_some(),
358352
))
359353
}
360354
_ => None,

guide/src/types/bool.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,17 @@ pub fn test_bool(input: bool) -> String {
4545
var_dump(test_bool(true)); // string(4) "Yes!"
4646
var_dump(test_bool(false)); // string(3) "No!"
4747
```
48+
49+
## Rust example, taking by reference
50+
51+
```rust,no_run
52+
# #![cfg_attr(windows, feature(abi_vectorcall))]
53+
# extern crate ext_php_rs;
54+
# use ext_php_rs::prelude::*;
55+
# use ext_php_rs::types;
56+
#[php_function]
57+
pub fn test_bool(input: &mut types::Zval) {
58+
input.reference_mut().unwrap().set_bool(false);
59+
}
60+
# fn main() {}
61+
```

0 commit comments

Comments
 (0)