Copy AsciiExt methods to [u8] directly

This is done in order to deprecate AsciiExt eventually. Note that
this commit contains a bunch of `cfg(stage0)` statements. This is
due to a new compiler feature I am using: the `slice_u8` lang item.
Once this lang item is available in the stage0 compiler, all those
cfg flags (and more) can be removed.
This commit is contained in:
Lukas Kalbertodt
2017-10-01 21:13:49 +02:00
parent 9e441c76f7
commit 5a1d11a733
2 changed files with 219 additions and 0 deletions

View File

@@ -389,6 +389,10 @@ impl AsciiExt for str {
}
}
// TODO(LukasKalbertodt): this impl block can be removed in the future. This is
// possible once the stage0 compiler is new enough to contain the inherent
// ascii methods for `[u8]`. See TODO comment further down.
#[cfg(stage0)]
#[stable(feature = "rust1", since = "1.0.0")]
impl AsciiExt for [u8] {
type Owned = Vec<u8>;
@@ -542,6 +546,12 @@ macro_rules! impl_by_delegating {
impl_by_delegating!(u8, u8);
impl_by_delegating!(char, char);
// TODO(LukasKalbertodt): the macro invocation should replace the impl block
// for `[u8]` above. But this is not possible until the stage0 compiler is new
// enough to contain the inherent ascii methods for `[u8]`.
#[cfg(not(stage0))]
impl_by_delegating!([u8], Vec<u8>);
/// An iterator over the escaped version of a byte.
///
/// This `struct` is created by the [`escape_default`] function. See its