Skip to content

Conversation

@varkor
Copy link
Contributor

@varkor varkor commented Feb 16, 2019

This chapter briefly describes the use of Kind, UnpackedKind and Subst.

This has been delayed long enough that I think it's worth getting something in the guide, just to provide some explanation. We can always extend this in the future with more examples.

Fixes #97.

`UnpackedKind`s first. This is done by calling the `.unpack()` method.

```rust
// An example of unpacking and packing a kind.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need imports here in order to make the example compile and pass travis

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this example compile and pass without importing the whole compiler? Usually, I just add rust,ignore...

Copy link
Contributor

@mark-i-m mark-i-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @varkor! r=me when travis is green

@mark-i-m mark-i-m merged commit d911ba1 into rust-lang:master Feb 18, 2019
@varkor varkor deleted the chapter-kinds branch February 19, 2019 00:03

## `Kind`
The actual `Kind` struct is optimised for space, storing the type, lifetime or
const as an interned pointer containing a mask identifying its kind (in the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lowest 2 bits are the "tag", a (bit) "mask" is what you use to "mask out" bits other than the ones you're interested in (e.g. let (tag, ptr) = (x & 0b11, x & !0b11); uses 0b11 to get the lowest 2 bits and !0b11 for everything else).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #287 to fix.

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.

4 participants