-
Notifications
You must be signed in to change notification settings - Fork 24
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
Implement std::ascii::AsciiExt
and std::ascii::OwnedAsciiExt
for Ascii
#3
Comments
Makes sense to me. There is no particular reason these
All stability markers were just copied from
Just remove |
That is a good source of information, thanks. I consider rethinking the stability of the items in the crate.
I didn't remove I'm also following the IO reform RFC in which the |
Again, the stability markers only have the meaning we give them. The point of moving things out of libstd is that you don’t have to provide the stability promises. It’s OK to make breaking/backward-incompatible changes as long as the version number is changed appropriately per SemVer. (Of course, as a library matures and gets more relied on, breaking changes should become infrequent and made more thoughtfully…) |
I had a very strong reliance on the stability markers. The discussion you linked above brought some new points about the stability markers to me I didn't consider before. You are right that respecting SemVer is usually enough for a library to not break code using it immediately. Thanks for making this clear to me. |
It all depends on how many compatibility promises you, as a library maintainer, want to make. "Zero promises", although maybe painful for users, is a valid position. Stability markers and SemVer are just tools to express this. The Rust ecosystem has a relatively strong convention on SemVer, but you don’t have to use it either. |
Motivation
Preliminary
While
str
guarantees statically that data of its type is valid UTF-8, the typeAscii
guarantees ASCII-conformance. Therefore the types[Ascii]
andstr
and their owned counterpartsVec<Ascii>
andString
should behave similar.Topic of this Issue
Ascii
provides functions liketo_uppercase()
andto_lowercase()
which can be applied to single ascii-characters. Currently such operations are not implemented on owned or borrowed strings of ascii-characters. As the typesVec<Ascii>
and[Ascii]
should be opaque manually implementing the iteration isn't recommended because it is a implementation detail of these types.Example:
Design
The types
String
andstr
provide functionality for converting to uppercase and lowercase with their implementations of the traitsstd::ascii::{AsciiExt, OwnedAsciiExt}
. These traits are intended for "[…] ASCII-subset only operations on string slices" and owned strings. Of courseVec<Ascii>
and[Ascii]
are subsets of ascii, they are equivalent so it's valid to implement them for the ascii only string types.Implement the traits:
The implementations use functionality present in
Ascii
if possible.Design flaws
std::ascii::{AsciiExt, OwnedAsciiExt}
are marked experimental. This shouldn't be a real issue as I expect this crate to follow the way conversions are done in the standard library.std::ascii::{AsciiExt, OwnedAsciiExt}
carry the infixascii
which is redundant in the case the traits are implemented onVec<Ascii>
,[Ascii]
andAscii
. This redundancy must be tolerated to achieve the goals described above.Drawbacks
Ascii
implements the same functionality in the functionsto_uppercase()
/to_ascii_uppercase()
andto_lowercase()
andto_ascii_lowercase()
.Further considerations after discussion
to_uppercase()
andto_lowercase()
onAscii
in favour of their equivalents inAsciiExt
. That removes the duplication mentioned in the drawbacks.The text was updated successfully, but these errors were encountered: