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

More methods for str boxes. (reduce Box<[u8]> ↔ Box<str> transmutes) #41258

Merged
merged 1 commit into from
Apr 26, 2017

Conversation

clarfonthey
Copy link
Contributor

@clarfonthey clarfonthey commented Apr 12, 2017

This is a follow-up to #41096 that adds safer methods for converting between Box<str> and Box<[u8]>. They're gated under a different feature from the &mut str methods because they may be too niche to include in public APIs, although having them internally helps reduce the number of transmutes the standard library uses.

What's added:

  • From<Box<str>> for Box<[u8]>
  • <Box<str>>::into_boxed_bytes (just calls Into::into)
  • alloc::str (new module)
  • from_boxed_utf8 and from_boxed_utf8_unchecked, defined in alloc:str, exported in collections::str
  • exports from_utf8_mut in collections::str (missed from previous PR)

@rust-highfive
Copy link
Collaborator

r? @brson

(rust_highfive has picked a reviewer for you, use r? to override)

@clarfonthey clarfonthey changed the title More methods for str boxes. More methods for str boxes. (reduce Box<[u8]> ↔ Box<str> transmutes) Apr 12, 2017
@clarfonthey clarfonthey force-pushed the str_box_extras branch 12 times, most recently from 62b6205 to 15a8d38 Compare April 13, 2017 01:31
@alexcrichton alexcrichton added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Apr 13, 2017
@clarfonthey clarfonthey force-pushed the str_box_extras branch 4 times, most recently from 116c9be to 112459d Compare April 13, 2017 18:08
@shepmaster
Copy link
Member

@brson's going to be globe-trotting for a bit, so...

r? @Kimundi

@rust-highfive rust-highfive assigned Kimundi and unassigned brson Apr 14, 2017
@arielb1 arielb1 added S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). labels Apr 15, 2017
@arielb1
Copy link
Contributor

arielb1 commented Apr 18, 2017

Thanks for the PR @clarcharr! Sorry for the delay - half of the team was on spring vacation. @Kimundi or some other reviewer will be looking at your PR soon.

@clarfonthey
Copy link
Contributor Author

No problem! Whenever someone gets around to it. :)

@alexcrichton
Copy link
Member

@bors: r=Kimundi

@bors
Copy link
Contributor

bors commented Apr 19, 2017

📌 Commit 112459d has been approved by Kimundi

@bors
Copy link
Contributor

bors commented Apr 20, 2017

☔ The latest upstream changes (presumably #41411) made this pull request unmergeable. Please resolve the merge conflicts.

@frewsxcv
Copy link
Member

FYI, my PR #41295 just landed which made a couple organizational changes to the Unstable Book. Namely, features are now divided into 'language features' and 'library features' which are different directories, so you'll unfortunately have to address the conflicts. You should be able to just run ./x.py test src/tools/tidy to see what needs to be changed after rebasing/merging in master. Sorry for the inconvenience and if you need any help with that let me know! I can address the merge conflicts for you if you want.

@bors
Copy link
Contributor

bors commented Apr 20, 2017

🔒 Merge conflict

@clarfonthey
Copy link
Contributor Author

Just rebased!

@@ -207,6 +207,7 @@
- [str_checked_slicing](library-features/str-checked-slicing.md)
- [str_escape](library-features/str-escape.md)
- [str_internals](library-features/str-internals.md)
- [str_box_extras](libaryr-features/str-box-extras.md)
Copy link
Member

Choose a reason for hiding this comment

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

libaryr

😬

Copy link
Contributor Author

Choose a reason for hiding this comment

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

shhhhhhh

@clarfonthey
Copy link
Contributor Author

(Rebased a second time and now it passes.)

@alexcrichton
Copy link
Member

Hm so looking this over, I fear that we're getting too aggressive with all of these conversions. For example functions like from_boxed_utf8 seem like you wouldn't actually wish to call them because in the case of a failure you lose the entire allocation.

@shepmaster shepmaster added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 21, 2017
@clarfonthey
Copy link
Contributor Author

That makes sense! I can remove that function for now if that seems best.

@alexcrichton
Copy link
Member

Ok, let's remove that function.

@clarfonthey
Copy link
Contributor Author

Removed for now. I also marked the alloc::str module itself as unstable.

@alexcrichton
Copy link
Member

Looks like Travis is failing?

@clarfonthey
Copy link
Contributor Author

Hopefully it should be fixed once Travis finishes!

@clarfonthey
Copy link
Contributor Author

(Travis passes.)

@alexcrichton
Copy link
Member

@bors: r=Kimundi

@bors
Copy link
Contributor

bors commented Apr 26, 2017

📌 Commit c66c6e9 has been approved by Kimundi

@bors
Copy link
Contributor

bors commented Apr 26, 2017

⌛ Testing commit c66c6e9 with merge dad9814...

bors added a commit that referenced this pull request Apr 26, 2017
More methods for str boxes. (reduce Box<[u8]> ↔ Box<str> transmutes)

This is a follow-up to #41096 that adds safer methods for converting between `Box<str>` and `Box<[u8]>`. They're gated under a different feature from the `&mut str` methods because they may be too niche to include in public APIs, although having them internally helps reduce the number of transmutes the standard library uses.

What's added:

* `From<Box<str>> for Box<[u8]>`
* `<Box<str>>::into_boxed_bytes` (just calls `Into::into`)
* `alloc::str` (new module)
* `from_boxed_utf8` and `from_boxed_utf8_unchecked`, defined in `alloc:str`, exported in `collections::str`
* exports `from_utf8_mut` in `collections::str` (missed from previous PR)
@bors
Copy link
Contributor

bors commented Apr 26, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: Kimundi
Pushing dad9814 to master...

@bors bors merged commit c66c6e9 into rust-lang:master Apr 26, 2017
@bors bors mentioned this pull request Apr 26, 2017
@clarfonthey clarfonthey deleted the str_box_extras branch April 28, 2017 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants