Sign In

arrayvec

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arrayvec - cargo Package Compare versions

Comparing version
0.7.1
to
0.7.2
+4
-3
.cargo_vcs_info.json
{
"git": {
"sha1": "0c866b32f019561875806bc7d949a0dd363a9f11"
}
}
"sha1": "67ec907a98c0f40c4b76066fed3c1af59d35cf6a"
},
"path_in_vcs": ""
}

@@ -6,8 +6,7 @@ # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO

# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you believe there's an error in this file please file an
# issue against the rust-lang/cargo repository. If you're
# editing this file be aware that the upstream Cargo.toml
# will likely look very different (and much more reasonable)
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.

@@ -17,3 +16,3 @@ [package]

name = "arrayvec"
version = "0.7.1"
version = "0.7.2"
authors = ["bluss"]

@@ -20,0 +19,0 @@ description = "A vector with fixed capacity, backed by an array (it can be stored on the stack too). Implements fixed capacity ArrayVec and ArrayString."

Recent Changes (arrayvec)
=========================
## 0.7.2
- Add `.as_mut_str()` to `ArrayString` by @clarfonthey
- Add `remaining_capacity` to `ArrayString` by @bhgomes
- Add `zero_filled` constructor by @c410-f3r
- Optimize `retain` by @TennyZhuang and @niklasf
- Make the following methods `const` by @bhgomes:
- len
- is_empty
- capacity
- is_full
- remaining_capacity
- CapacityError::new
## 0.7.1

@@ -5,0 +19,0 @@

@@ -85,7 +85,7 @@ use std::borrow::Borrow;

#[inline]
pub fn len(&self) -> usize { self.len as usize }
pub const fn len(&self) -> usize { self.len as usize }
/// Returns whether the string is empty.
#[inline]
pub fn is_empty(&self) -> bool { self.len() == 0 }
pub const fn is_empty(&self) -> bool { self.len() == 0 }

@@ -133,2 +133,24 @@ /// Create a new `ArrayString` from a `str`.

/// Create a new `ArrayString` value fully filled with ASCII NULL characters (`\0`). Useful
/// to be used as a buffer to collect external data or as a buffer for intermediate processing.
///
/// ```
/// use arrayvec::ArrayString;
///
/// let string = ArrayString::<16>::zero_filled();
/// assert_eq!(string.len(), 16);
/// ```
#[inline]
pub fn zero_filled() -> Self {
assert_capacity_limit!(CAP);
// SAFETY: `assert_capacity_limit` asserts that `len` won't overflow and
// `zeroed` fully fills the array with nulls.
unsafe {
ArrayString {
xs: MaybeUninit::zeroed().assume_init(),
len: CAP as _
}
}
}
/// Return the capacity of the `ArrayString`.

@@ -143,3 +165,3 @@ ///

#[inline(always)]
pub fn capacity(&self) -> usize { CAP }
pub const fn capacity(&self) -> usize { CAP }

@@ -156,4 +178,17 @@ /// Return if the `ArrayString` is completely filled.

/// ```
pub fn is_full(&self) -> bool { self.len() == self.capacity() }
pub const fn is_full(&self) -> bool { self.len() == self.capacity() }
/// Returns the capacity left in the `ArrayString`.
///
/// ```
/// use arrayvec::ArrayString;
///
/// let mut string = ArrayString::<3>::from("abc").unwrap();
/// string.pop();
/// assert_eq!(string.remaining_capacity(), 1);
/// ```
pub const fn remaining_capacity(&self) -> usize {
self.capacity() - self.len()
}
/// Adds the given char to the end of the string.

@@ -377,2 +412,7 @@ ///

/// Return a mutable string slice of the whole `ArrayString`.
pub fn as_mut_str(&mut self) -> &mut str {
self
}
fn as_ptr(&self) -> *const u8 {

@@ -379,0 +419,0 @@ self.xs.as_ptr() as *const u8

@@ -111,3 +111,3 @@

#[inline(always)]
pub fn len(&self) -> usize { self.len as usize }
pub const fn len(&self) -> usize { self.len as usize }

@@ -124,3 +124,3 @@ /// Returns whether the `ArrayVec` is empty.

#[inline]
pub fn is_empty(&self) -> bool { self.len() == 0 }
pub const fn is_empty(&self) -> bool { self.len() == 0 }

@@ -136,3 +136,3 @@ /// Return the capacity of the `ArrayVec`.

#[inline(always)]
pub fn capacity(&self) -> usize { CAP }
pub const fn capacity(&self) -> usize { CAP }

@@ -149,3 +149,3 @@ /// Return true if the `ArrayVec` is completely filled to its capacity, false otherwise.

/// ```
pub fn is_full(&self) -> bool { self.len() == self.capacity() }
pub const fn is_full(&self) -> bool { self.len() == self.capacity() }

@@ -161,3 +161,3 @@ /// Returns the capacity left in the `ArrayVec`.

/// ```
pub fn remaining_capacity(&self) -> usize {
pub const fn remaining_capacity(&self) -> usize {
self.capacity() - self.len()

@@ -501,3 +501,7 @@ }

while g.processed_len < original_len {
#[inline(always)]
fn process_one<F: FnMut(&mut T) -> bool, T, const CAP: usize, const DELETED: bool>(
f: &mut F,
g: &mut BackshiftOnDrop<'_, T, CAP>
) -> bool {
let cur = unsafe { g.v.as_mut_ptr().add(g.processed_len) };

@@ -508,5 +512,5 @@ if !f(unsafe { &mut *cur }) {

unsafe { ptr::drop_in_place(cur) };
continue;
return false;
}
if g.deleted_cnt > 0 {
if DELETED {
unsafe {

@@ -518,4 +522,17 @@ let hole_slot = g.v.as_mut_ptr().add(g.processed_len - g.deleted_cnt);

g.processed_len += 1;
true
}
// Stage 1: Nothing was deleted.
while g.processed_len != original_len {
if !process_one::<F, T, CAP, false>(&mut f, &mut g) {
break;
}
}
// Stage 2: Some elements were deleted.
while g.processed_len != original_len {
process_one::<F, T, CAP, true>(&mut f, &mut g);
}
drop(g);

@@ -522,0 +539,0 @@ }

@@ -15,3 +15,3 @@ use std::fmt;

/// Create a new `CapacityError` from `element`.
pub fn new(element: T) -> CapacityError<T> {
pub const fn new(element: T) -> CapacityError<T> {
CapacityError {

@@ -18,0 +18,0 @@ element: element,

@@ -776,3 +776,2 @@ extern crate arrayvec;

#[test]

@@ -790,1 +789,7 @@ fn test_arraystring_const_constructible() {

#[test]
fn test_arraystring_zero_filled_has_some_sanity_checks() {
let string = ArrayString::<4>::zero_filled();
assert_eq!(string.as_str(), "\0\0\0\0");
assert_eq!(string.len(), 4);
}

Sorry, the diff of this file is not supported yet