Giter Site home page Giter Site logo

#[repr(Rust)] layout about cheats.rs HOT 3 CLOSED

yhx-12243 avatar yhx-12243 commented on June 20, 2024
#[repr(Rust)] layout

from cheats.rs.

Comments (3)

ralfbiedert avatar ralfbiedert commented on June 20, 2024 1

The std docs for Vec say:

Most fundamentally, Vec is and always will be a (pointer, capacity, length) triplet. No more, no less. The order of these fields is completely unspecified [...]

However, they also give this specific example (pointer, capacity, length) for illustrative purposes; and I think we are no different in that respect.

That said, I can understand that the disclaimer we have is 1-2 pages away and it might be misleading for some people that jump into that section without reading the context; maybe repeating that hint might be warranted.

from cheats.rs.

ralfbiedert avatar ralfbiedert commented on June 20, 2024

Maybe I misunderstand, but we already have a disclaimer that you are not allowed to transmute unless you have representation guarantees which I think Vec doesn't give, neither for it being repr(C), nor for these fields to be in a particular order if it were.

So from that perspective all depictions are merely illustrative anyways, and the point is to depict what's contained, not where exactly that resides.

from cheats.rs.

yhx-12243 avatar yhx-12243 commented on June 20, 2024

What I means is that in Memory Layout > Standard Library Types chapter, the Vec<T> is drawn with a specific order. Is this appropriate (need not change) or to be changed?

Or maybe adding some comments will be better?

from cheats.rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.