Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace
Vec<Ascii>
and [Ascii]
with newtypes
The ascii crate now provides types for owned ascii strings and borrowed ascii slices. Their implementation should allow them to be used like `String` and `str`. Changes: - `AsciiString` replaces `Vec<Ascii>` - `AsciiStr` replaces `[Ascii]` Migration: - You can't construct `AsciiString` and `AsciiStr` like a collection anymore, use the `from_bytes` method instead. - To convert from the ascii types to bytes or strings please use the new generic conversion traits `Into` and `AsRef`. - The `AsciiCast` and `OwnedAsciiCast` traits are unchanged for now. Implementations: - `AsciiString::from_bytes` and `AsciiStr::from_bytes` for construction from types which can be represented as a byte slice. - Implements `fmt::{Debug, Display}` like `String` does - `AsciiString` derefs to `AsciiStr`, additionally `DerefMut` is implemented so `AsciiExt` is fully useable - Implements `Hash`, `Borrow` and `ToOwned` so it can easily be used in collections. - Implements `PartialEq`, `PartialOrd`, `Eq` and `Ord` for itself and `str` - `AsciiString` implements `Into<String>`, `Into<Vec<u8>>` and `AsRef<AsciiStr>` - `AsciiStr` implements `AsRef<[u8]>` and `AsRef<str>` [breaking-change]
- Loading branch information