cxx
cxx copied to clipboard
Translate #[must_use] attribute to C++17 [[nodiscard]]
References:
- https://doc.rust-lang.org/1.54.0/reference/attributes/diagnostics.html#the-must_use-attribute
- https://en.cppreference.com/w/cpp/language/attributes/nodiscard
#[cxx::bridge]
mod ffi {
#[must_use]
struct S {...}
extern "Rust" {
#[must_use = "..."]
type T;
#[must_use]
fn f() -> i32;
}
}
// generated c++
struct [[nodiscard]] S final {...};
struct [[nodiscard("...")]] T final : rust::Opaque {...};
[[nodiscard]] int32_t f() noexcept;