Skip to content

Conversation

@rcseacord
Copy link
Contributor

Coding guidelines based on #255

@netlify
Copy link

netlify bot commented Dec 6, 2025

Deploy Preview for scrc-coding-guidelines failed.

Name Link
🔨 Latest commit 1ae4332
🔍 Latest deploy log https://app.netlify.com/projects/scrc-coding-guidelines/deploys/6934feb40349b400088766c7


- 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
resolved comments from reviewers
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.

3 participants