-
Notifications
You must be signed in to change notification settings - Fork 28
ACP: impl TryFrom<char> for u16 #146
Copy link
Copy link
Closed
Labels
ACP-acceptedAPI Change Proposal is accepted (seconded with no objections)API Change Proposal is accepted (seconded with no objections)api-change-proposalA proposal to add or alter unstable APIs in the standard librariesA proposal to add or alter unstable APIs in the standard libraries
Description
Activity
Metadata
Metadata
Assignees
Labels
ACP-acceptedAPI Change Proposal is accepted (seconded with no objections)API Change Proposal is accepted (seconded with no objections)api-change-proposalA proposal to add or alter unstable APIs in the standard librariesA proposal to add or alter unstable APIs in the standard libraries
Proposal
Problem statement
Implement
TryFrom<char> for u16, similar to the existingTryFrom<char> for u8.Motivation, use-cases
I have project, which (unfortunately) has to deal with UCS-2 encoded strings (UCS-2 is like UTF-16, but no surrogates). I am currently in the process of replacing
ascasts with safer alternatives and found that this impl was missing.One example of using this feature for collecting an iterator of chars into a preallocated UCS-2 string: (playground)
Solution sketches
Copy-paste the impl from
u8, but replaceu8withu16:Links and related work
impl TryFrom<char> for u8: ImplementTryFrom<char>foru8rust#84640What happens now?
This issue is part of the libs-api team API change proposal process. Once this issue is filed the libs-api team will review open proposals in its weekly meeting. You should receive feedback within a week or two.