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

str::byte_slice_no_callback includes the trailing NULL #7019

Closed
SiegeLord opened this issue Jun 8, 2013 · 2 comments
Closed

str::byte_slice_no_callback includes the trailing NULL #7019

SiegeLord opened this issue Jun 8, 2013 · 2 comments

Comments

@SiegeLord
Copy link
Contributor

rustc 0.6 (9873f67 2013-06-04 17:55:34 -0700)

E.g. this assertion fails:

fn main()
{
    use std::str;
    assert_eq!(str::byte_slice_no_callback("a").len(), 1);
}

Notably, str::byte_slice and str::to_bytes work as expected.

@erickt
Copy link
Contributor

erickt commented Jun 9, 2013

I'm actually in the middle of fixing this right now :) Instead, you should use str::as_bytes_slice, which doesn't include the trailing NULL.

@huonw
Copy link
Member

huonw commented Jun 12, 2013

This is fixed by #7060 (the choices are now "a".as_bytes(), "a".as_bytes_with_null() and (~"a").as_bytes_with_null_consume()).

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

No branches or pull requests

4 participants