#![no_std]
use core::fmt::{self, Write};
use core::mem;
pub struct Slice<T>([T]);
impl<'a, T> From<&'a [T]> for &'a Slice<T> {
#[inline]
fn from(xs: &'a [T]) -> &'a Slice<T> { unsafe { mem::transmute(xs) } }
}
impl<'a, T> From<&'a mut [T]> for &'a mut Slice<T> {
#[inline]
fn from(xs: &'a mut [T]) -> &'a mut Slice<T> { unsafe { mem::transmute(xs) } }
}
impl<T: fmt::LowerHex> fmt::LowerHex for Slice<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_char('[')?;
for (k, x) in self.0.iter().enumerate() {
if k > 0 { f.write_str(", ")?; }
fmt::LowerHex::fmt(x, f)?;
}
f.write_char(']')?;
Ok(())
}
}
impl<T: fmt::UpperHex> fmt::UpperHex for Slice<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_char('[')?;
for (k, x) in self.0.iter().enumerate() {
if k > 0 { f.write_str(", ")?; }
fmt::UpperHex::fmt(x, f)?;
}
f.write_char(']')?;
Ok(())
}
}