mirror of
https://github.com/rust-embedded/heapless.git
synced 2025-09-28 13:00:26 +00:00
Merge pull request #200 from burrbull/const_generics
remove as_slice dependency
This commit is contained in:
commit
622eba960a
@ -33,7 +33,6 @@ __trybuild = []
|
||||
scoped_threadpool = "0.1.8"
|
||||
|
||||
[dependencies]
|
||||
as-slice = "0.2.0"
|
||||
hash32 = "0.1.0"
|
||||
|
||||
[dependencies.serde]
|
||||
|
@ -236,8 +236,6 @@ use core::{
|
||||
ptr,
|
||||
};
|
||||
|
||||
use as_slice::{AsMutSlice, AsSlice};
|
||||
|
||||
pub use stack::Node;
|
||||
use stack::{Ptr, Stack};
|
||||
|
||||
@ -384,13 +382,13 @@ impl<T> Pool<T> {
|
||||
/// memory block
|
||||
pub fn grow_exact<A>(&self, memory: &'static mut MaybeUninit<A>) -> usize
|
||||
where
|
||||
A: AsMutSlice<Element = Node<T>>,
|
||||
A: AsMut<[Node<T>]>,
|
||||
{
|
||||
if mem::size_of::<T>() == 0 {
|
||||
return usize::max_value();
|
||||
}
|
||||
|
||||
let nodes = unsafe { (*memory.as_mut_ptr()).as_mut_slice() };
|
||||
let nodes = unsafe { (*memory.as_mut_ptr()).as_mut() };
|
||||
let cap = nodes.len();
|
||||
for p in nodes {
|
||||
match () {
|
||||
@ -441,26 +439,6 @@ unsafe impl<T, S> Sync for Box<T, S> where T: Sync {}
|
||||
|
||||
unsafe impl<T> stable_deref_trait::StableDeref for Box<T> {}
|
||||
|
||||
impl<A> AsSlice for Box<A>
|
||||
where
|
||||
A: AsSlice,
|
||||
{
|
||||
type Element = A::Element;
|
||||
|
||||
fn as_slice(&self) -> &[A::Element] {
|
||||
self.deref().as_slice()
|
||||
}
|
||||
}
|
||||
|
||||
impl<A> AsMutSlice for Box<A>
|
||||
where
|
||||
A: AsMutSlice,
|
||||
{
|
||||
fn as_mut_slice(&mut self) -> &mut [A::Element] {
|
||||
self.deref_mut().as_mut_slice()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Deref for Box<T> {
|
||||
type Target = T;
|
||||
|
||||
|
@ -10,8 +10,6 @@ use core::{
|
||||
ptr,
|
||||
};
|
||||
|
||||
use as_slice::{AsMutSlice, AsSlice};
|
||||
|
||||
use super::{Init, Node, Uninit};
|
||||
|
||||
/// Instantiates a pool as a global singleton
|
||||
@ -80,7 +78,7 @@ pub trait Pool {
|
||||
/// memory block
|
||||
fn grow_exact<A>(memory: &'static mut MaybeUninit<A>) -> usize
|
||||
where
|
||||
A: AsMutSlice<Element = Node<Self::Data>>,
|
||||
A: AsMut<[Node<Self::Data>]>,
|
||||
{
|
||||
Self::ptr().grow_exact(memory)
|
||||
}
|
||||
@ -123,7 +121,7 @@ where
|
||||
impl<P> Box<P, Uninit>
|
||||
where
|
||||
P: Pool,
|
||||
P::Data: AsSlice<Element = u8>,
|
||||
P::Data: AsRef<[u8]>,
|
||||
{
|
||||
/// Freezes the contents of this memory block
|
||||
///
|
||||
@ -246,28 +244,6 @@ where
|
||||
{
|
||||
}
|
||||
|
||||
impl<P, T> AsSlice for Box<P>
|
||||
where
|
||||
P: Pool,
|
||||
P::Data: AsSlice<Element = T>,
|
||||
{
|
||||
type Element = T;
|
||||
|
||||
fn as_slice(&self) -> &[T] {
|
||||
self.deref().as_slice()
|
||||
}
|
||||
}
|
||||
|
||||
impl<P, T> AsMutSlice for Box<P>
|
||||
where
|
||||
P: Pool,
|
||||
P::Data: AsMutSlice<Element = T>,
|
||||
{
|
||||
fn as_mut_slice(&mut self) -> &mut [T] {
|
||||
self.deref_mut().as_mut_slice()
|
||||
}
|
||||
}
|
||||
|
||||
impl<P> PartialEq for Box<P>
|
||||
where
|
||||
P: Pool,
|
||||
|
Loading…
x
Reference in New Issue
Block a user