Skip to content

Consolidate raw representations of rust values #7986

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

alexcrichton
Copy link
Member

This moves the raw struct layout of closures, vectors, boxes, and strings into a
new unstable::raw module. This is meant to be a centralized location to find
information for the layout of these values.

As safe method, unwrap, is provided to convert a rust value to its raw
representation. Unsafe methods to convert back are not provided because they are
rarely used and too numerous to write an implementation for each (not much of a
common pattern).

This is progress on #6790. I tried to get a nice interface for a trait to implement in the raw module, but I was unable to come up with one. The hard part is that there are so many different directions to go from one way to another that it's difficult to find a pattern to follow to implement a trait with. Someone else might have some better luck though.

@brson
Copy link
Contributor

brson commented Jul 24, 2013

Looks like some good cleanups. 👍

@alexcrichton
Copy link
Member Author

@brson, @huonw, now it's

trait Repr { fn repr() }

@alexcrichton
Copy link
Member Author

@huonw pointed out that std::repr::Repr also exists, so for the sake of less confusion I've renamed the trait to his suggestion of RawRepr

r? @brson (just want to make sure this is ok with you)

@alexcrichton
Copy link
Member Author

Actually, after thinking about this some more, I like Repr better because that's why we have package namespaces. raw::Repr is different enough from repr::Repr that I prefer the shorter name.

This moves the raw struct layout of closures, vectors, boxes, and strings into a
new `unstable::raw` module. This is meant to be a centralized location to find
information for the layout of these values.

As safe method, `repr`, is provided to convert a rust value to its raw
representation. Unsafe methods to convert back are not provided because they are
rarely used and too numerous to write an implementation for each (not much of a
common pattern).
bors added a commit that referenced this pull request Jul 27, 2013
This moves the raw struct layout of closures, vectors, boxes, and strings into a
new `unstable::raw` module. This is meant to be a centralized location to find
information for the layout of these values.

As safe method, `unwrap`, is provided to convert a rust value to its raw
representation. Unsafe methods to convert back are not provided because they are
rarely used and too numerous to write an implementation for each (not much of a
common pattern).

This is progress on #6790. I tried to get a nice interface for a trait to implement in the raw module, but I was unable to come up with one. The hard part is that there are so many different directions to go from one way to another that it's difficult to find a pattern to follow to implement a trait with. Someone else might have some better luck though.
@bors bors closed this Jul 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants