Skip to content

Commit 28b8cac

Browse files
author
Thomas Bahn
committed
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]
1 parent 75804a2 commit 28b8cac

File tree

1 file changed

+344
-146
lines changed

1 file changed

+344
-146
lines changed

0 commit comments

Comments
 (0)