Why does Rust bindgen have bitfields?

This page summarizes the projects mentioned and recommended in the original post on /r/rust

CodeRabbit: AI Code Reviews for Developers
Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.
coderabbit.ai
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  1. go

    The Go programming language

    How does Golang deal with this? It doesn't. And to be fair, Rust doesn't either.

  2. CodeRabbit

    CodeRabbit: AI Code Reviews for Developers. Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.

    CodeRabbit logo
  3. rfcs

    RFCs for changes to Rust

    How does Golang deal with this? It doesn't. And to be fair, Rust doesn't either.

  4. rust-bindgen

    Automatically generates Rust FFI bindings to C (and some C++) libraries.

    But then why does bindgen attempt to have bitfields at all. Yes, I see the unsafe but wouldn't it be "safer" to recommend exporting C helper getter/setter functions to deal with this? I actually don't understand how any crate can say they have "C-compatible" bitfields.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Security vulnerability in Rust standard library

    4 projects | news.ycombinator.com | 21 Jan 2022
  • Go’ing Insane: Endless Error Handling

    5 projects | news.ycombinator.com | 14 Sep 2021
  • 5 Best Programming Languages to Learn: Decoding the Future

    4 projects | dev.to | 22 Feb 2025
  • Perhaps Rust Needs "Defer"

    2 projects | news.ycombinator.com | 6 Nov 2024
  • Lisp Implemented in Rust Macros

    6 projects | news.ycombinator.com | 13 Sep 2024

Did you know that Go is
the 4th most popular programming language
based on number of references?