Description
Ideally we should be able to do something like this:
Cargo.toml:
.....
[lib]
path = "src/lib.rs"
crate-type = ["rlib","dylib"]
.....
src/lib.rs:
....
#[no_mangle]
#[cfg(crate_type="dylib")]
pub unsafe extern "C" fn .....
To allow only exporting the c api in the dylib or perhaps in the dylib and static lib and not in the rust code.
This would be consistent with being able to build multiple library formats but allow the unsafe c methods to not be exported to rust code.
I checked against: http://doc.rust-lang.org/reference.html#conditional-compilation
and did some experimentation myself, with no luck.
If anyone has any better suggestions, I'd love to hear them.
I'm looking to generate very similar rust and c libraries with similar apis where the c library is just a c style wrapper around the rust api, also written in rust. Ideally i'd keep this in a single source and conditionally define the c api's in the dylib for loading from various languages with c ffi's and exclude the c api from the rust lib.