Skip to content

Commit de0278a

Browse files
committed
add HasAfEnum trait bound and size check to Array::host method
1 parent 8481527 commit de0278a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/array.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,10 @@ impl Array {
308308
}
309309

310310
/// Copies the data from the Array to the mutable slice `data`
311-
pub fn host<T>(&self, data: &mut [T]) {
311+
pub fn host<T: HasAfEnum>(&self, data: &mut [T]) {
312+
if data.len() != self.elements() {
313+
HANDLE_ERROR(AfError::ERR_SIZE);
314+
}
312315
unsafe {
313316
let err_val = af_get_data_ptr(data.as_mut_ptr() as *mut c_void, self.handle as AfArray);
314317
HANDLE_ERROR(AfError::from(err_val));

0 commit comments

Comments
 (0)