Do you ever use unsafe { .. } when not implementing custom data structures or interacting with external C code?

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

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • miri

    An interpreter for Rust's mid-level intermediate representation

  • Also, we have fantastic tools like miri to make sure that any unsafe blocks are actually safe. So you can even install some new guard rails for your unsafe block!

  • rust

    Empowering everyone to build reliable and efficient software.

  • You should almost* never use static mut, as it's mostly impossible to use correctly, to the point that there have been discussions about deprecating it (https://github.com/rust-lang/rust/issues/53639). Especially with multithreaded code, as it should use atomics/mutex instead.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • safety-dance

    Auditing crates for unsafe code which can be safely replaced

  • The most "virtuous"/desirable statement in this topic is probably the "100% safe code now - while being faster than the C version!" on the rust-secure-code/safety-dance entry for miniz_oxide.

  • rand

    A Rust library for random number generation.

  • You can often achieve this without any unsafe by putting an assert!() on the length before the hot loop. For example, I got rid of some unsafe in rand that way.

  • zune-jpeg

    Discontinued A jpeg decoder with wings

  • Alternatively, you can round up the array length to the nearest power of 2 and use cheap bitmasking instead of branching bounds checks. If it goes wrong, it will access the wrong element but will not result in any code execution vulnerabilities. Here's an example of this in zune-jpeg.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
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