Add internal functions to rust

  • my idea is to add functions that are public but can be only used inside a crate

example

i am making a embedded systems crate in rust and i made an unsafe function on the crate to be internally used on the crate but i don't want anyone using this crate because it could lead to memory issues

example code

intern fn unsafe_function() {
// uninplemented
}

Are you looking for pub(crate)?

Also, if the caller must satisfy some safety invariant, the function should probably be marked unsafe.

pub(crate) unsafe fn unsafe_function() {
    todo!()
}
5 Likes

It must be marked unsafe if it can lead to memory issues (assuming that means Undefined Behavior)

oh yes i forgot unsafe thanks

thanks, i forogot to put unsafe

Unlisting, as requested by OP :slight_smile: