There is a variadic C function that I cannot call outside of a macro. This macro is public which it should be, but the C function with variadic arguments should not be visible.
Is there any way to only make it visible for inside of the macro? Or maybe a way to keep the function outside of the docs?
The only thing you can do is hide such "internal" symbols such that they do not appear in the documentation. For example:
#[macro_export]
macro_rules! custom_abort {
($($args:tt)*) => {
match format!($($args)*) {
msg => $crate::custom_abort__(&msg)
}
};
}
/// This is an implementation detail and *should not* be called directly!
#[doc(hidden)]
pub fn custom_abort__(msg: &str) -> ! {
use std::io::Write;
let _ = writeln!(std::io::stderr(), "{}", msg);
std::process::exit(1);
}
As you might expect, this absolutely does not prevent someone from calling custom_abort__
directly. But really, if someone ignores warnings in the comments and does so anyway, feel free to laugh at them when their code breaks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With