Merge pull request #79 from bluss/promise-debug-checks
Promise debug assertions for unsafe methods
This commit is contained in:
+3
-2
@@ -322,10 +322,11 @@ impl<A: Array<Item=u8>> ArrayString<A> {
|
|||||||
|
|
||||||
/// Set the strings's length.
|
/// Set the strings's length.
|
||||||
///
|
///
|
||||||
/// May panic if `length` is greater than the capacity.
|
|
||||||
///
|
|
||||||
/// This function is `unsafe` because it changes the notion of the
|
/// This function is `unsafe` because it changes the notion of the
|
||||||
/// number of “valid” bytes in the string. Use with care.
|
/// number of “valid” bytes in the string. Use with care.
|
||||||
|
///
|
||||||
|
/// This method uses *debug assertions* to check the validity of `length`
|
||||||
|
/// and may use other debug assertions.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn set_len(&mut self, length: usize) {
|
pub unsafe fn set_len(&mut self, length: usize) {
|
||||||
debug_assert!(length <= self.capacity());
|
debug_assert!(length <= self.capacity());
|
||||||
|
|||||||
+5
-5
@@ -226,7 +226,7 @@ impl<A: Array> ArrayVec<A> {
|
|||||||
/// It is up to the caller to ensure the capacity of the vector is
|
/// It is up to the caller to ensure the capacity of the vector is
|
||||||
/// sufficiently large.
|
/// sufficiently large.
|
||||||
///
|
///
|
||||||
/// This method *may* use debug assertions to check that the arrayvec is not full.
|
/// This method uses *debug assertions* to check that the arrayvec is not full.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use arrayvec::ArrayVec;
|
/// use arrayvec::ArrayVec;
|
||||||
@@ -502,11 +502,11 @@ impl<A: Array> ArrayVec<A> {
|
|||||||
|
|
||||||
/// Set the vector's length without dropping or moving out elements
|
/// Set the vector's length without dropping or moving out elements
|
||||||
///
|
///
|
||||||
/// May use debug assertions to check that `length` is not greater than the
|
/// This method is `unsafe` because it changes the notion of the
|
||||||
/// capacity.
|
|
||||||
///
|
|
||||||
/// This function is `unsafe` because it changes the notion of the
|
|
||||||
/// number of “valid” elements in the vector. Use with care.
|
/// number of “valid” elements in the vector. Use with care.
|
||||||
|
///
|
||||||
|
/// This method uses *debug assertions* to check that check that `length` is
|
||||||
|
/// not greater than the capacity.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn set_len(&mut self, length: usize) {
|
pub unsafe fn set_len(&mut self, length: usize) {
|
||||||
debug_assert!(length <= self.capacity());
|
debug_assert!(length <= self.capacity());
|
||||||
|
|||||||
Reference in New Issue
Block a user