• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1{{#title Function pointers — Rust ♡ C++}}
2# Function pointers
3
4### Public API:
5
6```cpp,hidelines
7// rust/cxx.h
8#
9# namespace rust {
10
11template <typename Signature>
12class Fn;
13
14template <typename Ret, typename... Args>
15class Fn<Ret(Args...)> final {
16public:
17  Ret operator()(Args... args) const noexcept;
18  Fn operator*() const noexcept;
19};
20#
21# } // namespace rust
22```
23
24### Restrictions:
25
26Function pointers with a Result return type are not implemented yet.
27
28Passing a function pointer from C++ to Rust is not implemented yet, only from
29Rust to an `extern "C++"` function is implemented.
30
31## Example
32
33Function pointers are commonly useful for implementing [async functions over
34FFI](../async.md). See the example code on that page.
35