Skip to content

Commit

Permalink
Replace Vec<Ascii> and [Ascii] with newtypes
Browse files Browse the repository at this point in the history
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
Thomas Bahn committed Apr 3, 2015
1 parent 75804a2 commit 28b8cac
Showing 1 changed file with 344 additions and 146 deletions.
Loading

0 comments on commit 28b8cac

Please sign in to comment.