Skip to content

RFC: For custom string types, add ability to define newtyped unsized vectors once DST gets implemented #9077

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
Kimundi opened this issue Sep 9, 2013 · 3 comments

Comments

@Kimundi
Copy link
Member

Kimundi commented Sep 9, 2013

Right now, the DST proposal is still not implemented/decide upon. However, once it gets implemented I'd like to propose the following roadmap:

  1. Implement ability to declare newtypes of at least unsized vectors (syntax just arbitrary):

    struct vec<T>[T];
    

    Those types would work the same way as a bare [T] works: They don't have a compile-time known size, and are specially represented by an slice or an owned pointer:

    let vec_slice: &'static vec<uint> = &'static vec[1, 2, 3];
    let owned_vec: ~vec<i8>           = ~vec[4, 5, 6];
    
  2. Remove str from the compiler and replace with an library type:

    struct str[u8];
    

    This would allow to clean up a lot of library types:

    struct str_ascii[u8];
    struct str_c[u8];
    
    struct str_utf16[u16]; // Servo seems to need utf16
    
  3. Rewrite string library to share as much code with traits and generics as possibly for those types.

@annevk
Copy link

annevk commented Sep 9, 2013

To be clear, Servo doesn't need utf-16, it needs 16-bit code units. utf-16 has the same value space as utf-8, 16-bit code units don't.

@Kimundi
Copy link
Member Author

Kimundi commented Sep 9, 2013

Ah, you're right. Still, the ability to newtype [u16] as str_usc2 or so could be useful.

@alexcrichton
Copy link
Member

Closing for now. DST is still very up-in-the-air (but maybe getting close soon?).

This can be revisited if and when we get DST.

flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 18, 2022
…ring_to_pedantic, r=flip1995

Move format_push_string to restriction

Fixes rust-lang#9077 (kinda) by moving the lint to the restriction group. As I noted in that issue, I think the suggested change is too much and as the OP of the issue points out, the ramifications of the change are not necessarily easily understood. As such I don't think the lint should be enabled by default.

changelog: [`format_push_string`]: moved to restriction (see rust-lang#9077).
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

3 participants