File tree Expand file tree Collapse file tree 1 file changed +19
-10
lines changed Expand file tree Collapse file tree 1 file changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -244,6 +244,16 @@ where
244
244
}
245
245
}
246
246
247
+ /// Generate a [`TryFromSliceError`] if the slice doesn't match the given length.
248
+ fn check_slice_length < T , U : Unsigned > ( slice : & [ T ] ) -> Result < ( ) , TryFromSliceError > {
249
+ if slice. len ( ) != U :: USIZE {
250
+ // Hack: `TryFromSliceError` lacks a public constructor
251
+ <& [ T ; 1 ] >:: try_from ( [ ] . as_slice ( ) ) ?;
252
+ }
253
+
254
+ Ok ( ( ) )
255
+ }
256
+
247
257
/// Byte array type.
248
258
pub type ByteArray < U > = Array < u8 , U > ;
249
259
@@ -398,6 +408,15 @@ macro_rules! impl_array_size {
398
408
}
399
409
}
400
410
411
+ impl <T > Default for Array <T , typenum:: $ty>
412
+ where
413
+ T : Default
414
+ {
415
+ fn default ( ) -> Self {
416
+ Self ( [ ( ) ; $len] . map( |_| T :: default ( ) ) )
417
+ }
418
+ }
419
+
401
420
impl <T > IntoIterator for Array <T , typenum:: $ty> {
402
421
type Item = T ;
403
422
type IntoIter = IntoIter <T , $len>;
@@ -512,13 +531,3 @@ impl_array_size! {
512
531
4096 => U4096 ,
513
532
8192 => U8192
514
533
}
515
-
516
- /// Generate a [`TryFromSliceError`] if the slice doesn't match the given length.
517
- fn check_slice_length < T , U : Unsigned > ( slice : & [ T ] ) -> Result < ( ) , TryFromSliceError > {
518
- if slice. len ( ) != U :: USIZE {
519
- // Hack: `TryFromSliceError` lacks a public constructor
520
- <& [ T ; 1 ] >:: try_from ( [ ] . as_slice ( ) ) ?;
521
- }
522
-
523
- Ok ( ( ) )
524
- }
You can’t perform that action at this time.
0 commit comments