Skip to content
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

Update sample code with stable alloc crate #161

Closed
wants to merge 6 commits into from

Conversation

tesuji
Copy link
Contributor

@tesuji tesuji commented Aug 24, 2019

Based on #170 .

src/vec-alloc.md Show resolved Hide resolved
src/vec-insert-remove.md Outdated Show resolved Hide resolved
src/vec-insert-remove.md Show resolved Hide resolved
src/vec-insert-remove.md Show resolved Hide resolved
self.ptr.as_ptr().offset(index as isize),
self.len - index,
);

Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you reformatting the code?

src/vec-raw.md Show resolved Hide resolved
buf.ptr.as_ptr()
} else {
buf.ptr.as_ptr().offset(len as isize)
},
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 pretty sure this is unnecessary, but it's fair this isn't documented properly.

rust-lang/rust#65108

src/vec-zsts.md Outdated Show resolved Hide resolved
src/vec-zsts.md Show resolved Hide resolved
src/vec-zsts.md Outdated Show resolved Hide resolved
@tesuji tesuji force-pushed the update-alloc-vec branch 2 times, most recently from a73218c to 91582ca Compare October 25, 2019 20:00
@tesuji tesuji requested a review from Gankra October 26, 2019 03:26
@CreepySkeleton
Copy link
Contributor

CreepySkeleton commented Nov 4, 2019

@lzutao could you please also replace Unique with NonNull so it finally works on stable?

@tesuji
Copy link
Contributor Author

tesuji commented Nov 4, 2019

@CreepySkeleton Thanks for the interest.
I don't think NonNull could replace Unique. Could you elaborate more about that?
If you want to read about Unique, here is the link: https://doc.rust-lang.org/nightly/src/core/ptr/unique.rs.html#8

@CreepySkeleton
Copy link
Contributor

CreepySkeleton commented Nov 4, 2019

@lzutao
What's similar between NonNull and Unique

  • They both cannot be null
  • Both are pointers
  • Both are covariant over T

Unique's features NonNull lacks:

  • notNull is neither Send nor Sync because it can be aliased. But the implementation guarantees that the pointer won't ever be aliased so I believe we can just do this
    unsafe impl<T: Send> Send for Vec<T> {}
    unsafe impl<T: Sync> Sync for Vec<T> {}

AFAIK, that's all. As we can see, in this case Unique can be replaced by NonNull very well.

@clifton
Copy link

clifton commented Dec 30, 2019

ill close #182 as its a duplicate (although just covering all aspects of the vec example) but may be worth looking to see if theres anything worth adding from there.

it would be good to merge in something like this, as i was not able to get any of the examples to compile on nightly and im sure others have the same problem.

@tesuji
Copy link
Contributor Author

tesuji commented Jun 3, 2020

I have no interest in continuing this PR.

@tesuji tesuji closed this Jun 3, 2020
@tesuji tesuji deleted the update-alloc-vec branch June 3, 2020 13:36
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