mirror of
https://github.com/rust-embedded/heapless.git
synced 2025-09-27 12:30:35 +00:00
Merge #18
18: Add AsMut and AsRef implementations for Vec and String r=japaric a=glandium And a cleanup commit removing unused `#![features]`
This commit is contained in:
commit
76f26e28e7
@ -92,9 +92,7 @@
|
||||
#![deny(missing_docs)]
|
||||
#![deny(warnings)]
|
||||
#![feature(const_fn)]
|
||||
#![feature(const_unsafe_cell_new)]
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(shared)]
|
||||
#![feature(unsize)]
|
||||
#![no_std]
|
||||
|
||||
|
@ -426,6 +426,26 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<A> AsRef<str> for String<A>
|
||||
where
|
||||
A: Unsize<[u8]>,
|
||||
{
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &str {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<A> AsRef<[u8]> for String<A>
|
||||
where
|
||||
A: Unsize<[u8]>,
|
||||
{
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &[u8] {
|
||||
self.as_bytes()
|
||||
}
|
||||
}
|
||||
|
||||
impl<A, B> PartialEq<String<B>> for String<A>
|
||||
where
|
||||
A: Unsize<[u8]>,
|
||||
|
40
src/vec.rs
40
src/vec.rs
@ -243,6 +243,46 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, A> AsRef<Vec<T, A>> for Vec<T, A>
|
||||
where
|
||||
A: Unsize<[T]>,
|
||||
{
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &Vec<T, A> {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, A> AsMut<Vec<T, A>> for Vec<T, A>
|
||||
where
|
||||
A: Unsize<[T]>,
|
||||
{
|
||||
#[inline]
|
||||
fn as_mut(&mut self) -> &mut Vec<T, A> {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, A> AsRef<[T]> for Vec<T, A>
|
||||
where
|
||||
A: Unsize<[T]>,
|
||||
{
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &[T] {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, A> AsMut<[T]> for Vec<T, A>
|
||||
where
|
||||
A: Unsize<[T]>,
|
||||
{
|
||||
#[inline]
|
||||
fn as_mut(&mut self) -> &mut [T] {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use Vec;
|
||||
|
Loading…
x
Reference in New Issue
Block a user