Skip to content

Commit 4152ffc

Browse files
committed
Remove infallible variants
1 parent eff7b01 commit 4152ffc

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

guide/src/types/functions.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ PHP functions and methods are represented by the `Function` struct.
55
You can use the `try_from_function` and `try_from_method` methods to obtain a Function struct corresponding to the passed function or static method name.
66
It's heavily recommended you reuse returned `Function` objects, to avoid the overhead of looking up the function/method name.
77

8-
You may also use the infallible `from_function` and `from_method` variants, for example when working with native PHP functions/classes that are guaranteed to be always available.
9-
108
```rust,no_run
119
# #![cfg_attr(windows, feature(abi_vectorcall))]
1210
# extern crate ext_php_rs;
@@ -16,13 +14,13 @@ use ext_php_rs::zend::Function;
1614
1715
#[php_function]
1816
pub fn test_function() -> () {
19-
let var_dump = Function::from_function("var_dump");
17+
let var_dump = Function::try_from_function("var_dump").unwrap();
2018
let _ = var_dump.try_call(vec![&"abc"]);
2119
}
2220
2321
#[php_function]
2422
pub fn test_method() -> () {
25-
let f = Function::from_method("ClassName", "staticMethod");
23+
let f = Function::try_from_method("ClassName", "staticMethod").unwrap();
2624
let _ = f.try_call(vec![&"abc"]);
2725
}
2826

src/zend/function.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,6 @@ impl Function {
7676
}
7777
}
7878

79-
pub fn from_function(name: &str) -> Self {
80-
match Self::try_from_function(name) {
81-
Some(v) => v,
82-
None => panic!("Expected function `{}` to exist!", name),
83-
}
84-
}
85-
86-
pub fn from_method(class: &str, name: &str) -> Self {
87-
match Self::try_from_method(class, name) {
88-
Some(v) => v,
89-
None => panic!("Expected method `{}::{}` to exist!", class, name),
90-
}
91-
}
92-
9379
/// Attempts to call the callable with a list of arguments to pass to the
9480
/// function.
9581
///

0 commit comments

Comments
 (0)