File tree 1 file changed +11
-2
lines changed
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -3,15 +3,20 @@ use std::hash::{BuildHasher, Hash};
3
3
4
4
/// The trait required to be able to use a type in `BytePool`.
5
5
pub trait Poolable {
6
+ fn len ( & self ) -> usize ;
6
7
fn capacity ( & self ) -> usize ;
7
8
fn alloc ( size : usize ) -> Self ;
8
9
}
9
10
10
11
impl < T : Default + Clone > Poolable for Vec < T > {
11
- fn capacity ( & self ) -> usize {
12
+ fn len ( & self ) -> usize {
12
13
self . len ( )
13
14
}
14
15
16
+ fn capacity ( & self ) -> usize {
17
+ self . capacity ( )
18
+ }
19
+
15
20
fn alloc ( size : usize ) -> Self {
16
21
vec ! [ T :: default ( ) ; size]
17
22
}
@@ -22,10 +27,14 @@ where
22
27
K : Eq + Hash ,
23
28
S : BuildHasher + Default ,
24
29
{
25
- fn capacity ( & self ) -> usize {
30
+ fn len ( & self ) -> usize {
26
31
self . len ( )
27
32
}
28
33
34
+ fn capacity ( & self ) -> usize {
35
+ self . capacity ( )
36
+ }
37
+
29
38
fn alloc ( size : usize ) -> Self {
30
39
HashMap :: with_capacity_and_hasher ( size, Default :: default ( ) )
31
40
}
You can’t perform that action at this time.
0 commit comments