Skip to content

Improved some things in std::ascii #7199

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

Closed
wants to merge 1 commit into from
Closed

Conversation

Kimundi
Copy link
Member

@Kimundi Kimundi commented Jun 17, 2013

  • Fixed tests
  • Added methods
  • Renamed casting methods to be shorter
  • Added unsafe versions

Closes #7150

- Fixed tests
- Added methods
- Renamed casting methods to be shorter

closes rust-lang#7150
@@ -96,8 +105,13 @@ impl<'self> AsciiCast<&'self[Ascii]> for &'self str {
#[inline(always)]
fn to_ascii(&self) -> &'self[Ascii] {
assert!(self.is_ascii());
let (p,len): (*u8, uint) = unsafe{ cast::transmute(*self) };
unsafe{ cast::transmute((p, len - 1))}
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the point of len in these lines? Why isn't it necessary any more?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's still necessary, it just happens in the unsafe method below it. It's for adjusting the &str so that the last hidden byte it includes does not end up in the &[Ascii].

bors added a commit that referenced this pull request Jun 17, 2013
- Fixed tests
- Added methods
- Renamed casting methods to be shorter
- Added unsafe versions

Closes #7150
@bors bors closed this Jun 17, 2013
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.

std::ascii needs some improvements
3 participants