summaryrefslogtreecommitdiffstats
path: root/vendor/thin-vec
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:25 +0000
commit5363f350887b1e5b5dd21a86f88c8af9d7fea6da (patch)
tree35ca005eb6e0e9a1ba3bb5dbc033209ad445dc17 /vendor/thin-vec
parentAdding debian version 1.66.0+dfsg1-1. (diff)
downloadrustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.tar.xz
rustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.zip
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/thin-vec')
-rw-r--r--vendor/thin-vec/.cargo-checksum.json2
-rw-r--r--vendor/thin-vec/Cargo.toml2
-rw-r--r--vendor/thin-vec/src/lib.rs75
3 files changed, 70 insertions, 9 deletions
diff --git a/vendor/thin-vec/.cargo-checksum.json b/vendor/thin-vec/.cargo-checksum.json
index fc4888d7f..33ca74234 100644
--- a/vendor/thin-vec/.cargo-checksum.json
+++ b/vendor/thin-vec/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"596cca0e2a5b1abe635e3fcdd3fa1f5f7256a5f2abf63b9c6bba0cce32258b02","README.md":"9f102f13ccbabe9cdec7a206aa298d65e33dea84da9f08dd17b358ff44fe0286","src/lib.rs":"d6300952a66dc289328a464b466f4b281272b133e42e20e1e2cd0e6f8690087d"},"package":"104c2cb3180b6fb6d5b2278768e9b88b578d32ba751ea6e8d026688a40d7ed87"} \ No newline at end of file
+{"files":{"Cargo.toml":"49f429a38e2c6216dfddc1f23af64a3b06cf92217d75cae2a9ac389bc3f76e46","README.md":"9f102f13ccbabe9cdec7a206aa298d65e33dea84da9f08dd17b358ff44fe0286","src/lib.rs":"6a5451d75037e3cb12bde5198266a0db00432e1370cad74b0dda8df8fb64f067"},"package":"ceb05e71730d396f960f8f3901cdb41be2d339b303e9d7d3a07c5ff0536e671b"} \ No newline at end of file
diff --git a/vendor/thin-vec/Cargo.toml b/vendor/thin-vec/Cargo.toml
index 38908830d..8361d94d4 100644
--- a/vendor/thin-vec/Cargo.toml
+++ b/vendor/thin-vec/Cargo.toml
@@ -12,7 +12,7 @@
[package]
edition = "2018"
name = "thin-vec"
-version = "0.2.8"
+version = "0.2.9"
authors = ["Aria Beingessner <a.beingessner@gmail.com>"]
description = "A vec that takes up less space on the stack"
homepage = "https://github.com/gankra/thin-vec"
diff --git a/vendor/thin-vec/src/lib.rs b/vendor/thin-vec/src/lib.rs
index 60785150e..a2384c62e 100644
--- a/vendor/thin-vec/src/lib.rs
+++ b/vendor/thin-vec/src/lib.rs
@@ -403,7 +403,9 @@ unsafe impl<T: Send> Send for ThinVec<T> {}
/// Creates a `ThinVec` containing the arguments.
///
-/// ```
+// A hack to avoid linking problems with `cargo test --features=gecko-ffi`.
+#[cfg_attr(not(feature = "gecko-ffi"), doc = "```")]
+#[cfg_attr(feature = "gecko-ffi", doc = "```ignore")]
/// #[macro_use] extern crate thin_vec;
///
/// fn main() {
@@ -771,7 +773,9 @@ impl<T> ThinVec<T> {
///
/// # Examples
///
- /// ```
+ // A hack to avoid linking problems with `cargo test --features=gecko-ffi`.
+ #[cfg_attr(not(feature = "gecko-ffi"), doc = "```")]
+ #[cfg_attr(feature = "gecko-ffi", doc = "```ignore")]
/// # #[macro_use] extern crate thin_vec;
/// # fn main() {
/// let mut vec = thin_vec![1, 2, 3, 4];
@@ -783,13 +787,41 @@ impl<T> ThinVec<T> {
where
F: FnMut(&T) -> bool,
{
+ self.retain_mut(|x| f(&*x));
+ }
+
+ /// Retains only the elements specified by the predicate, passing a mutable reference to it.
+ ///
+ /// In other words, remove all elements `e` such that `f(&mut e)` returns `false`.
+ /// This method operates in place and preserves the order of the retained
+ /// elements.
+ ///
+ /// # Examples
+ ///
+ // A hack to avoid linking problems with `cargo test --features=gecko-ffi`.
+ #[cfg_attr(not(feature = "gecko-ffi"), doc = "```")]
+ #[cfg_attr(feature = "gecko-ffi", doc = "```ignore")]
+ /// # #[macro_use] extern crate thin_vec;
+ /// # fn main() {
+ /// let mut vec = thin_vec![1, 2, 3, 4, 5];
+ /// vec.retain_mut(|x| {
+ /// *x += 1;
+ /// (*x)%2 == 0
+ /// });
+ /// assert_eq!(vec, [2, 4, 6]);
+ /// # }
+ /// ```
+ pub fn retain_mut<F>(&mut self, mut f: F)
+ where
+ F: FnMut(&mut T) -> bool,
+ {
let len = self.len();
let mut del = 0;
{
let v = &mut self[..];
for i in 0..len {
- if !f(&v[i]) {
+ if !f(&mut v[i]) {
del += 1;
} else if del > 0 {
v.swap(i - del, i);
@@ -807,7 +839,9 @@ impl<T> ThinVec<T> {
///
/// # Examples
///
- /// ```
+ // A hack to avoid linking problems with `cargo test --features=gecko-ffi`.
+ #[cfg_attr(not(feature = "gecko-ffi"), doc = "```")]
+ #[cfg_attr(feature = "gecko-ffi", doc = "```ignore")]
/// # #[macro_use] extern crate thin_vec;
/// # fn main() {
/// let mut vec = thin_vec![10, 20, 21, 30, 20];
@@ -835,7 +869,9 @@ impl<T> ThinVec<T> {
///
/// # Examples
///
- /// ```
+ // A hack to avoid linking problems with `cargo test --features=gecko-ffi`.
+ #[cfg_attr(not(feature = "gecko-ffi"), doc = "```")]
+ #[cfg_attr(feature = "gecko-ffi", doc = "```ignore")]
/// # #[macro_use] extern crate thin_vec;
/// # fn main() {
/// let mut vec = thin_vec!["foo", "bar", "Bar", "baz", "bar"];
@@ -1014,7 +1050,9 @@ impl<T: Clone> ThinVec<T> {
///
/// # Examples
///
- /// ```
+ // A hack to avoid linking problems with `cargo test --features=gecko-ffi`.
+ #[cfg_attr(not(feature = "gecko-ffi"), doc = "```")]
+ #[cfg_attr(feature = "gecko-ffi", doc = "```ignore")]
/// # #[macro_use] extern crate thin_vec;
/// # fn main() {
/// let mut vec = thin_vec!["hello"];
@@ -1056,7 +1094,9 @@ impl<T: PartialEq> ThinVec<T> {
///
/// # Examples
///
- /// ```
+ // A hack to avoid linking problems with `cargo test --features=gecko-ffi`.
+ #[cfg_attr(not(feature = "gecko-ffi"), doc = "```")]
+ #[cfg_attr(feature = "gecko-ffi", doc = "```ignore")]
/// # #[macro_use] extern crate thin_vec;
/// # fn main() {
/// let mut vec = thin_vec![1, 2, 2, 3, 2];
@@ -1814,6 +1854,15 @@ mod tests {
{
let mut v = ThinVec::<i32>::new();
+ v.retain_mut(|_| unreachable!());
+
+ assert_eq!(v.len(), 0);
+ assert_eq!(v.capacity(), 0);
+ assert_eq!(&v[..], &[]);
+ }
+
+ {
+ let mut v = ThinVec::<i32>::new();
v.dedup_by_key(|x| *x);
assert_eq!(v.len(), 0);
@@ -2090,6 +2139,18 @@ mod std_tests {
}
#[test]
+ fn test_retain_mut() {
+ let mut vec = thin_vec![9, 9, 9, 9];
+ let mut i = 0;
+ vec.retain_mut(|x| {
+ i += 1;
+ *x = i;
+ i != 4
+ });
+ assert_eq!(vec, [1, 2, 3]);
+ }
+
+ #[test]
fn test_dedup() {
fn case(a: ThinVec<i32>, b: ThinVec<i32>) {
let mut v = a;