Make core::str::from_utf8*
methods available on the str
type
#398
Labels
ACP-accepted
API Change Proposal is accepted (seconded with no objections)
api-change-proposal
A proposal to add or alter unstable APIs in the standard libraries
T-libs-api
Proposal
Problem statement
These are constructors for
str
, but they live in thecore::str
module. This means users always need ause core::str
import in order to call them asstr::from_utf8
, or have to fully qualify them. This leads to two ways of doing things, and is also confusing for beginners who might think thatcore::str
imports the type and is always needed when usingstr
.Motivating examples or use cases
Solution sketch
from_utf8
from_utf8_mut
from_utf8_unchecked
from_utf8_unchecked_mut
become associated functions on the
str
type. Thecore::str
module reexports them, with a future deprecation warning, as was done forcore::i16::MAX
and friends.Alternatives
Everything stays as it is
Links and related work
str_from_raw_parts
rust#119206 adds additional constructors, these should be included if they get stabilised.Open questions
str_internals
functions,next_code_point
andutf8_char_width
, not sure whether to include those.The text was updated successfully, but these errors were encountered: