Closed porky11 closed 6 years ago
No, this is not currently possible.
It might be possible to do something like this (allowing opaque C++ types to exist on the Rust stack - you'd still need cpp! blocks to call methods on the types) once we get something like impl trait
or if I decide that implicit boxing and virtual call overhead is OK.
@mystor, btw, why would you need impl Trait for this?
I'm not sure if I would. I had one idea for how to implement it which would require it but I haven't had time to think through the options.
I thought you were talking about creating opaque structs of the same size and alignment as their C++ counterparts.
This is now possible with cpp_class! from https://github.com/mystor/rust-cpp/pull/28
#[macro_use]
extern crate cpp;
cpp!{{
#include <glm/glm.hpp>
}}
cpp_class!(unsafe struct vec3 as "glm::vec3");
fn main() {
let x = unsafe { cpp!( [] -> vec3 as "glm::vec3" { return glm::vec3(1,0,0)]; }) };
}
Is it, or will it be possible to use types from c++? I didn't find that in the documentation nor in the tests. I'd like something like that: