Rfcs: Make `str` a `struct str([u8])`

Created on 23 Apr 2019  路  1Comment  路  Source: rust-lang/rfcs

This was previously attempted in https://github.com/rust-lang/rust/pull/19612, but since https://github.com/rust-lang/rust/pull/45225 some of the issues are no longer relevant, so it may be feasible to try this again.

See also Make bool an enum.

A-primitive A-string T-lang

Most helpful comment

https://github.com/rust-lang/rust/pull/19612#issuecomment-66661255

Allows for inherent methods on str -- but note, it does not allow us to do away with extension traits because some of the operators must be defined in liballoc.

These days we do have inherent methods on str, both in libcore and in liballoc, through lang items that allow these impl blocks despite usual impl coherence rules. If str becomes a struct in libcore, it will still need at least a lang item for liballoc methods.

>All comments

https://github.com/rust-lang/rust/pull/19612#issuecomment-66661255

Allows for inherent methods on str -- but note, it does not allow us to do away with extension traits because some of the operators must be defined in liballoc.

These days we do have inherent methods on str, both in libcore and in liballoc, through lang items that allow these impl blocks despite usual impl coherence rules. If str becomes a struct in libcore, it will still need at least a lang item for liballoc methods.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

p-avital picture p-avital  路  3Comments

clarfonthey picture clarfonthey  路  3Comments

steveklabnik picture steveklabnik  路  4Comments

torkleyy picture torkleyy  路  3Comments

burdges picture burdges  路  3Comments