Macro cxx::let_cxx_string

source ·
macro_rules! let_cxx_string {
    ($var:ident = $value:expr $(,)?) => { ... };
Expand description

Construct a C++ std::string on the Rust stack.


In statement position:

let_cxx_string!(var = expression);

The expression may have any type that implements AsRef<[u8]>. Commonly it will be a string literal, but for example &[u8] and String would work as well.

The macro expands to something resembling let $var: Pin<&mut CxxString> = /*???*/;. The resulting Pin can be deref’d to &CxxString as needed.


use cxx::{let_cxx_string, CxxString};

fn f(s: &CxxString) {/* ... */}

fn main() {
    let_cxx_string!(s = "example");