File tree 1 file changed +15
-10
lines changed
1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -356,16 +356,21 @@ impl Buffer {
356
356
}
357
357
}
358
358
359
- /// Creating a `Buffer` instance by copying the memory from a `AsRef<[u8]>` into a newly
360
- /// allocated memory region.
361
- impl < T : AsRef < [ u8 ] > > From < T > for Buffer {
362
- fn from ( p : T ) -> Self {
363
- // allocate aligned memory buffer
364
- let slice = p. as_ref ( ) ;
365
- let len = slice. len ( ) ;
366
- let mut buffer = MutableBuffer :: new ( len) ;
367
- buffer. extend_from_slice ( slice) ;
368
- buffer. into ( )
359
+ impl From < & [ u8 ] > for Buffer {
360
+ fn from ( p : & [ u8 ] ) -> Self {
361
+ Self :: from_slice_ref ( p)
362
+ }
363
+ }
364
+
365
+ impl < const N : usize > From < [ u8 ; N ] > for Buffer {
366
+ fn from ( p : [ u8 ; N ] ) -> Self {
367
+ Self :: from_slice_ref ( p)
368
+ }
369
+ }
370
+
371
+ impl < const N : usize > From < & [ u8 ; N ] > for Buffer {
372
+ fn from ( p : & [ u8 ; N ] ) -> Self {
373
+ Self :: from_slice_ref ( p)
369
374
}
370
375
}
371
376
You can’t perform that action at this time.
0 commit comments