Skip to content

Consolidate raw representations of rust values - #7986

Closed
alexcrichton wants to merge 2 commits into
rust-lang:masterfrom
alexcrichton:raw-repr
Closed

alexcrichton wants to merge 2 commits into
rust-lang:masterfrom
alexcrichton:raw-repr

Conversation

@alexcrichton

Copy link
Copy Markdown
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

brson commented Jul 24, 2013

Copy link
Copy Markdown
Contributor

Looks like some good cleanups. 👍

@alexcrichton

Copy link
Copy Markdown
Member Author

@brson, @huonw, now it's

trait Repr { fn repr() }

@alexcrichton

Copy link
Copy Markdown
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
Copy Markdown
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
U007D pushed a commit to U007D/rust-mos that referenced this pull request Aug 21, 2026
7986: Simplify a bit r=flodiebold a=flodiebold



Co-authored-by: Florian Diebold <flodiebold@gmail.com>
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