Merge pull request #921 from OfficialURL/ptr_alias

Fixed potential UB
This commit is contained in:
Sébastien Crozet 2021-06-18 09:49:41 +02:00 committed by GitHub
commit 0312981a4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -1,7 +1,7 @@
//! Abstract definition of a matrix data storage.
use std::fmt::Debug;
use std::mem;
use std::ptr;
use crate::base::allocator::{Allocator, SameShapeC, SameShapeR};
use crate::base::default_allocator::DefaultAllocator;
@ -158,7 +158,7 @@ pub unsafe trait StorageMut<T: Scalar, R: Dim, C: Dim = U1>: Storage<T, R, C> {
let a = self.get_address_unchecked_linear_mut(i1);
let b = self.get_address_unchecked_linear_mut(i2);
mem::swap(&mut *a, &mut *b);
ptr::swap(a, b);
}
/// Swaps two elements without bound-checking.