25
25
26
26
#![ crate_type = "lib" ]
27
27
#![ crate_name = "fixedvec" ]
28
-
29
28
#![ no_std]
30
29
31
30
//! Heapless Vec implementation using only libcore
@@ -150,10 +149,10 @@ extern crate std;
150
149
/// ```
151
150
#[ macro_export]
152
151
macro_rules! alloc_stack {
153
- ( [ $item_type: ty; $len: expr] ) => ( {
154
- let space: [ $item_type; $len] = [ Default :: default ( ) ; $len ] ;
152
+ ( [ $item_type: ty; $len: expr] ) => { {
153
+ let space: [ $item_type; $len] = [ Default :: default ( ) ; $len] ;
155
154
space
156
- } )
155
+ } } ;
157
156
}
158
157
159
158
pub type Result < T > = core:: result:: Result < T , ErrorKind > ;
@@ -173,7 +172,8 @@ pub use core::slice::Iter;
173
172
pub use core:: slice:: IterMut ;
174
173
175
174
impl < ' a , T > FixedVec < ' a , T >
176
- where T : ' a + Copy
175
+ where
176
+ T : ' a + Copy ,
177
177
{
178
178
/// Create a new `FixedVec` from the provided slice, in the process taking
179
179
/// ownership of the slice.
@@ -540,7 +540,8 @@ impl<'a, T> FixedVec<'a, T>
540
540
/// # }
541
541
/// ```
542
542
pub fn map_in_place < F > ( & mut self , f : F )
543
- where F : Fn ( & mut T )
543
+ where
544
+ F : Fn ( & mut T ) ,
544
545
{
545
546
for i in 0 ..self . len {
546
547
f ( & mut self . memory [ i] ) ;
@@ -573,7 +574,6 @@ impl<'a, T> FixedVec<'a, T>
573
574
slice. iter ( )
574
575
}
575
576
576
-
577
577
/// Provides a mutable forward iterator.
578
578
///
579
579
/// # Example
@@ -595,7 +595,7 @@ impl<'a, T> FixedVec<'a, T>
595
595
/// ```
596
596
#[ inline]
597
597
pub fn iter_mut ( & mut self ) -> IterMut < T > {
598
- let ( mut slice, _) = self . memory . split_at_mut ( self . len ) ;
598
+ let ( slice, _) = self . memory . split_at_mut ( self . len ) ;
599
599
slice. iter_mut ( )
600
600
}
601
601
@@ -690,7 +690,8 @@ impl<'a, T> FixedVec<'a, T>
690
690
/// # }
691
691
/// ```
692
692
pub fn retain < F > ( & mut self , f : F )
693
- where F : Fn ( & T ) -> bool
693
+ where
694
+ F : Fn ( & T ) -> bool ,
694
695
{
695
696
let mut head: usize = 0 ;
696
697
let mut tail: usize = 0 ;
@@ -807,7 +808,8 @@ impl<'a, T> FixedVec<'a, T>
807
808
}
808
809
809
810
impl < ' a , T > FixedVec < ' a , T >
810
- where T : ' a + Copy + PartialEq < T >
811
+ where
812
+ T : ' a + Copy + PartialEq < T > ,
811
813
{
812
814
/// Removes consecutive repeated elements in the vector in O(N) time.
813
815
///
@@ -859,13 +861,14 @@ impl<'a, T: Copy> IntoIterator for &'a mut FixedVec<'a, T> {
859
861
type Item = & ' a mut T ;
860
862
type IntoIter = IterMut < ' a , T > ;
861
863
862
- fn into_iter ( mut self ) -> IterMut < ' a , T > {
864
+ fn into_iter ( self ) -> IterMut < ' a , T > {
863
865
self . iter_mut ( )
864
866
}
865
867
}
866
868
867
869
impl < ' a , T > Hash for FixedVec < ' a , T >
868
- where T : Copy + Hash
870
+ where
871
+ T : Copy + Hash ,
869
872
{
870
873
#[ inline]
871
874
fn hash < H : Hasher > ( & self , state : & mut H ) {
@@ -874,7 +877,8 @@ impl<'a, T> Hash for FixedVec<'a, T>
874
877
}
875
878
876
879
impl < ' a , T > Extend < T > for FixedVec < ' a , T >
877
- where T : Copy
880
+ where
881
+ T : Copy ,
878
882
{
879
883
fn extend < I : IntoIterator < Item = T > > ( & mut self , iterable : I ) {
880
884
if self . available ( ) == 0 {
@@ -891,7 +895,8 @@ impl<'a, T> Extend<T> for FixedVec<'a, T>
891
895
}
892
896
893
897
impl < ' a , T > ops:: Index < usize > for FixedVec < ' a , T >
894
- where T : Copy
898
+ where
899
+ T : Copy ,
895
900
{
896
901
type Output = T ;
897
902
@@ -902,7 +907,8 @@ impl<'a, T> ops::Index<usize> for FixedVec<'a, T>
902
907
}
903
908
904
909
impl < ' a , T > ops:: IndexMut < usize > for FixedVec < ' a , T >
905
- where T : Copy
910
+ where
911
+ T : Copy ,
906
912
{
907
913
#[ inline]
908
914
fn index_mut ( & mut self , index : usize ) -> & mut T {
@@ -911,7 +917,8 @@ impl<'a, T> ops::IndexMut<usize> for FixedVec<'a, T>
911
917
}
912
918
913
919
impl < ' a , T > PartialEq for FixedVec < ' a , T >
914
- where T : Copy + PartialEq
920
+ where
921
+ T : Copy + PartialEq ,
915
922
{
916
923
fn eq ( & self , other : & FixedVec < ' a , T > ) -> bool {
917
924
if self . len ( ) != other. len ( ) {
@@ -927,9 +934,9 @@ impl<'a, T> Eq for FixedVec<'a, T> where T: Copy + Eq {}
927
934
#[ cfg( test) ]
928
935
mod test {
929
936
use super :: FixedVec ;
930
- use std:: prelude:: v1:: * ;
931
- use std:: hash:: Hash ;
932
937
use std:: collections:: hash_map:: DefaultHasher ;
938
+ use std:: hash:: Hash ;
939
+ use std:: prelude:: v1:: * ;
933
940
934
941
#[ test]
935
942
fn test_empty_array ( ) {
0 commit comments