• svn
    link
    fedilink
    104 months ago

    You can wrap everything in unsafe and keep living dangerously!

    • Ephera
      link
      fedilink
      English
      44 months ago

      unsafe doesn’t deactivate memory safety. It only allows you to then create raw pointers and whatnot, which you could use to circumvent memory safety, but all the normal language constructs still do enforce it.

      • svn
        link
        fedilink
        34 months ago

        I know, but it does let you sled off a cliff if you choose to.

    • @yetAnotherUser@lemmy.ca
      link
      fedilink
      14 months ago

      Tsoding has created a few rules for writing Rust to make Rust “fun” to program in, and gave them the name of Crust.

      Here is the rule set (it may change over time):

      1. Every function is unsafe.
      2. No references, only pointers.
      3. No cargo, build with rustc directly.
      4. No std, but libc is allowed.
      5. Only Edition 2021.
      6. All user structs and enums #[derive(Clone, Copy)].
      7. Everything is pub by default.

      If you ever want to try this out for some ungodly reason, there’s a GitHub repository with an example Main that shows how to use libc and other libraries (in the example, it’s raylib), and with a Makefile showing how to compile your projects (remember we aren’t using cargo).

      • svn
        link
        fedilink
        14 months ago

        Oh boy, now I can stop missing C++