Skip to content

Consider adding CString/*const i8 literals #400

Closed
@rust-highfive

Description

@rust-highfive

Issue by canndrew
Wednesday Oct 15, 2014 at 15:59 GMT

For earlier discussion, see rust-lang/rust#18065

This issue was labelled with: B-RFC, I-enhancement in the Rust repository


There's already b"foo" syntax for [u8] literals and I've seen talk of adding s"foo" for String literals (perhaps through a syntax extension). If we're going down that path we could also add c"foo" syntax which could be either a CString or a *const i8. This would be useful for interacting with foreign C code. Currently, to call a C function with a string constant I'm using

foo(b"my string\0".as_ptr() as *const i8)

But that's a little cumbersome (and error-prone if I accidentally leave the NUL off).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions