this post was submitted on 20 Nov 2025
41 points (100.0% liked)

Rust

7507 readers
14 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] TehPers@beehaw.org 2 points 2 days ago (1 children)
#[unsafe(export_name = "my_super_duper_function")]
pub fn foo() {}

I would recommend reading up some materials on FFI in Rust if you're interested. Calling functions in Rust from C and in C from Rust (or even languages other than C) is both extremely common and a primary usecase of the language.

[–] INeedMana@piefed.zip 1 points 2 days ago (1 children)

Wouldn't that make the body of the function unsafe too?

I would recommend reading up some materials on FFI in Rust

Yeah, I'm slowly getting to that

[–] TehPers@beehaw.org 3 points 2 days ago

No, the attribute is unsafe. An unsafe function is marked unsafe fn.

Also, unsafe by itself just means there are invariants that must me manually upheld to avoid unsound behavior. If those invariants are upheld, then it doesn't matter if it's unsafe.