Skip to content

Conversation

@rcseacord
Copy link
Collaborator

Coding guidelines based on #255

@netlify
Copy link

netlify bot commented Dec 6, 2025

Deploy Preview for scrc-coding-guidelines ready!

Name Link
🔨 Latest commit 4398ef0
🔍 Latest deploy log https://app.netlify.com/projects/scrc-coding-guidelines/deploys/6940cf3d343ed600081d0c06
😎 Deploy Preview https://deploy-preview-256--scrc-coding-guidelines.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.


- Comparing function pointers for equality (``fn1 == fn2``)
- Assuming a unique function address
- Using function pointers as identity keys (e.g., in maps, registries, matchers)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can still use function pointers as keys, they just don't have a one-to-one relationship to function items, so you can't rely on a function item giving the same function pointer or different items giving different pointers. (ignoring #[no_mangle]). so e.g. you can have a HashSet<fn()> and it works just fine as long as you don't assume inserting any particular function item does anything other than guaranteeing calling one or more of the entries is equivalent to calling that function item.

@rcseacord rcseacord changed the title [Coding Guideline]: Do Not Depend on Function Pointer Identity Across Crates [Coding Guideline]: Do Not Depend on Function Pointer Identity Dec 7, 2025
@felix91gr
Copy link
Collaborator

felix91gr commented Dec 15, 2025

@rcseacord you'll want to consider this discussion before the guideline is ready for merge rust-lang/unsafe-code-guidelines#589, since it addresses the same topic

@PLeVasseur
Copy link
Collaborator

FYI @rcseacord @manhatsu -- I got this building again, aside from the code examples, see: #287

Feel free to just yoink the commit from there and replace the commits on this feature branch (i.e. cherry-pick that commit I linked above onto your local updated main, then force-push to your remote branch).

That way we keep all the comment history from on here.

(The coding examples also need to be updated to compile)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants