• ProgrammingSocks@pawb.social
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    7 months ago

    Rust simply doesn’t allow you to have references to data that goes out of scope (unless previously mentioned hoops are jumped through such as an explicitly declared unsafe block). It’s checked at compile time. You will never be able to compile the program.

    Rust isn’t C. Rust isn’t C++. The memory-safe-ness of it is also not magic, it’s a series of checks in the compiler.

    • DacoTaco@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      7 months ago

      That sounds odd. That also means that a mapper, command, service,… can never return a class object or entity. Most of the programming world is based on oop o.O
      Keep in mind im not talking about the usage of pointers, but reference typed variables.

      • ProgrammingSocks@pawb.social
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        7 months ago

        Oh sure, I’m still learning so I thought you meant references as in pointers like in C++. But also, Rust isn’t a strictly object oriented language either. It shares a lot of similar features, but they aren’t all the typical way you’d do things in an OOP language. You should check out the chapter of the Rust book for ownership.