Skip to content

Conversation

Zoxc
Copy link

@Zoxc Zoxc commented Jul 21, 2014

struct FieldOffset<Obj, Field>;

impl FieldOffset<Obj, Field> {
pub fn get(obj: &T) -> &FieldType;
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is the FieldType type introduced? (typo?)

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm assuming the Field parameter is supposed to be FieldType.

@lilyball
Copy link
Contributor

I just wrote a long comment on #174 about associated values in conjunction with field offsets that I think provides a potentially-compelling reason to have field offsets.

@bgamari
Copy link

bgamari commented Jul 22, 2014

@Zoxc for what it's worth here is a possible implementation of an intrusive linked list without needing field offsets. It does require a helper trait, but I think this trick should work for many cases where field offsets would be useful.

@huonw
Copy link
Contributor

huonw commented Jul 22, 2014

BTW, RFCs should not be rebased or amended; any changes should be made with new commits.

@Zoxc
Copy link
Author

Zoxc commented Jul 29, 2014

This should probably be postponed until #56 or something like that lands in order to provide greater motivation.

@brson
Copy link
Contributor

brson commented Aug 1, 2014

I believe that the broad goal here is to provide better support for 'intrusive' data structures, which Rust is currently weak at. It's not clear that this is the design to solve that problem, and @pcwalton has some ideas for designing intrusive data structures without changing the language.

offsetof is certainly a potentially useful operator, and for that the keyword is already reserved.

Closing. Thank you.

@brson brson closed this Aug 1, 2014
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.

5 participants