@@ -376,6 +376,31 @@ where
376
376
}
377
377
378
378
/// Copies the data from the Array to the mutable slice `data`
379
+ ///
380
+ /// # Examples
381
+ ///
382
+ /// Basic case
383
+ /// ```
384
+ /// # use arrayfire::{Array,Dim4,HasAfEnum};
385
+ /// let a:Vec<u8> = vec![0,1,2,3,4,5,6,7,8];
386
+ /// let b = Array::<u8>::new(&a,Dim4::new(&[3,3,1,1]));
387
+ /// let mut c = vec!(u8::default();b.elements());
388
+ /// b.host(&mut c);
389
+ /// assert_eq!(c,a);
390
+ /// ```
391
+ /// Generic case
392
+ /// ```
393
+ /// # use arrayfire::{Array,Dim4,HasAfEnum};
394
+ /// fn to_vec<T:HasAfEnum+Default+Clone>(array:&Array<T>) -> Vec<T> {
395
+ /// let mut vec = vec!(T::default();array.elements());
396
+ /// array.host(&mut vec);
397
+ /// return vec;
398
+ /// }
399
+ ///
400
+ /// let a = Array::<u8>::new(&[0,1,2,3,4,5,6,7,8],Dim4::new(&[3,3,1,1]));
401
+ /// let b:Vec<u8> = vec![0,1,2,3,4,5,6,7,8];
402
+ /// assert_eq!(to_vec(&a),b);
403
+ /// ```
379
404
pub fn host < O : HasAfEnum > ( & self , data : & mut [ O ] ) {
380
405
if data. len ( ) != self . elements ( ) {
381
406
HANDLE_ERROR ( AfError :: ERR_SIZE ) ;
0 commit comments