Skip to content

Commit 622eba9

Browse files
authored
Merge pull request #200 from burrbull/const_generics
remove as_slice dependency
2 parents 870a925 + e0b3b3a commit 622eba9

File tree

3 files changed

+4
-51
lines changed

3 files changed

+4
-51
lines changed

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ __trybuild = []
3333
scoped_threadpool = "0.1.8"
3434

3535
[dependencies]
36-
as-slice = "0.2.0"
3736
hash32 = "0.1.0"
3837

3938
[dependencies.serde]

src/pool/mod.rs

+2-24
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,6 @@ use core::{
236236
ptr,
237237
};
238238

239-
use as_slice::{AsMutSlice, AsSlice};
240-
241239
pub use stack::Node;
242240
use stack::{Ptr, Stack};
243241

@@ -384,13 +382,13 @@ impl<T> Pool<T> {
384382
/// memory block
385383
pub fn grow_exact<A>(&self, memory: &'static mut MaybeUninit<A>) -> usize
386384
where
387-
A: AsMutSlice<Element = Node<T>>,
385+
A: AsMut<[Node<T>]>,
388386
{
389387
if mem::size_of::<T>() == 0 {
390388
return usize::max_value();
391389
}
392390

393-
let nodes = unsafe { (*memory.as_mut_ptr()).as_mut_slice() };
391+
let nodes = unsafe { (*memory.as_mut_ptr()).as_mut() };
394392
let cap = nodes.len();
395393
for p in nodes {
396394
match () {
@@ -441,26 +439,6 @@ unsafe impl<T, S> Sync for Box<T, S> where T: Sync {}
441439

442440
unsafe impl<T> stable_deref_trait::StableDeref for Box<T> {}
443441

444-
impl<A> AsSlice for Box<A>
445-
where
446-
A: AsSlice,
447-
{
448-
type Element = A::Element;
449-
450-
fn as_slice(&self) -> &[A::Element] {
451-
self.deref().as_slice()
452-
}
453-
}
454-
455-
impl<A> AsMutSlice for Box<A>
456-
where
457-
A: AsMutSlice,
458-
{
459-
fn as_mut_slice(&mut self) -> &mut [A::Element] {
460-
self.deref_mut().as_mut_slice()
461-
}
462-
}
463-
464442
impl<T> Deref for Box<T> {
465443
type Target = T;
466444

src/pool/singleton.rs

+2-26
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ use core::{
1010
ptr,
1111
};
1212

13-
use as_slice::{AsMutSlice, AsSlice};
14-
1513
use super::{Init, Node, Uninit};
1614

1715
/// Instantiates a pool as a global singleton
@@ -80,7 +78,7 @@ pub trait Pool {
8078
/// memory block
8179
fn grow_exact<A>(memory: &'static mut MaybeUninit<A>) -> usize
8280
where
83-
A: AsMutSlice<Element = Node<Self::Data>>,
81+
A: AsMut<[Node<Self::Data>]>,
8482
{
8583
Self::ptr().grow_exact(memory)
8684
}
@@ -123,7 +121,7 @@ where
123121
impl<P> Box<P, Uninit>
124122
where
125123
P: Pool,
126-
P::Data: AsSlice<Element = u8>,
124+
P::Data: AsRef<[u8]>,
127125
{
128126
/// Freezes the contents of this memory block
129127
///
@@ -246,28 +244,6 @@ where
246244
{
247245
}
248246

249-
impl<P, T> AsSlice for Box<P>
250-
where
251-
P: Pool,
252-
P::Data: AsSlice<Element = T>,
253-
{
254-
type Element = T;
255-
256-
fn as_slice(&self) -> &[T] {
257-
self.deref().as_slice()
258-
}
259-
}
260-
261-
impl<P, T> AsMutSlice for Box<P>
262-
where
263-
P: Pool,
264-
P::Data: AsMutSlice<Element = T>,
265-
{
266-
fn as_mut_slice(&mut self) -> &mut [T] {
267-
self.deref_mut().as_mut_slice()
268-
}
269-
}
270-
271247
impl<P> PartialEq for Box<P>
272248
where
273249
P: Pool,

0 commit comments

Comments
 (0)