Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
pczarn authored Nov 29, 2024
2 parents 06dd7a5 + 3aa9da1 commit c669b1f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 92 deletions.
42 changes: 12 additions & 30 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Build
run: cargo build --verbose
- name: Run tests
Expand All @@ -25,7 +25,7 @@ jobs:
name: "Miri"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install Miri
run: |
rustup toolchain install nightly --component miri
Expand All @@ -37,51 +37,33 @@ jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
profile: minimal
components: rustfmt
override: true
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- run: cargo fmt --all -- --check


clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
profile: minimal
components: clippy
override: true
- uses: actions-rs/clippy-check@v1
env:
PWD: ${{ env.GITHUB_WORKSPACE }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --workspace --tests --examples
- run: cargo clippy --workspace --tests --examples


docs:
runs-on: ubuntu-latest
env:
RUSTDOCFLAGS: -Dwarnings
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
profile: minimal
components: rust-docs
override: true
- uses: swatinem/rust-cache@v1
- uses: actions-rs/cargo@v1
with:
command: doc
args: --workspace --no-deps
- uses: swatinem/rust-cache@v2
- run: cargo doc --workspace --no-deps
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ authors = ["Alex Crichton <alex@alexcrichton.com>",
"Vadim Petrochenkov <>"]

edition = "2018"
license = "MIT/Apache-2.0"
license = "MIT OR Apache-2.0"
description = "A simple map based on a vector for small integer keys"
repository = "https://github.com/contain-rs/vec-map"
homepage = "https://github.com/contain-rs/vec-map"
documentation = "https://contain-rs.github.io/vec-map/vec_map"
keywords = ["data-structures", "collections", "vecmap", "vec_map", "contain-rs"]
readme = "README.md"
exclude = ["/.travis.yml", "/deploy-docs.sh"]
exclude = ["/deploy-docs.sh"]

[features]
serde = ["dep:serde", "allocator-api2/serde"]
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
![Rust CI](https://github.com/contain-rs/vec-map/workflows/Rust/badge.svg?branch=master) [![crates.io](https://img.shields.io/crates/v/vec-map.svg)](https://crates.io/crates/vec-map) [![](https://docs.rs/vec-map/badge.svg)](https://docs.rs/vec-map)

[![Rust](https://github.com/contain-rs/vec-map/actions/workflows/rust.yml/badge.svg)](https://github.com/contain-rs/vec-map/actions/workflows/rust.yml)
[![crates.io](https://img.shields.io/crates/v/vec_map.svg)](https://crates.io/crates/vec_map)
[![](https://docs.rs/vec_map/badge.svg)](https://docs.rs/vec_map)


**WARNING: THIS PROJECT IS IN MAINTENANCE MODE, DUE TO INSUFFICIENT MAINTAINER RESOURCES**

Expand All @@ -14,4 +18,4 @@ We are currently only accepting changes which:

A simple map based on a vector for small integer keys.

Documentation is available at https://contain-rs.github.io/vec-map/vec_map.
Documentation is available at <https://docs.rs/vec_map>.
49 changes: 12 additions & 37 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,20 @@ pub struct VecMap<V, A: Allocator = Global> {

/// A view into a single entry in a map, which may either be vacant or occupied.
pub enum Entry<'a, V, A: Allocator = Global> {
/// A vacant Entry
/// A vacant `Entry`
Vacant(VacantEntry<'a, V, A>),

/// An occupied Entry
/// An occupied `Entry`
Occupied(OccupiedEntry<'a, V, A>),
}

/// A vacant Entry.
/// A vacant `Entry`.
pub struct VacantEntry<'a, V, A: Allocator = Global> {
map: &'a mut VecMap<V, A>,
index: usize,
}

/// An occupied Entry.
/// An occupied `Entry`.
pub struct OccupiedEntry<'a, V, A: Allocator = Global> {
map: &'a mut VecMap<V, A>,
index: usize,
Expand Down Expand Up @@ -571,6 +571,9 @@ impl<V, A: Allocator> VecMap<V, A> {
/// Inserts a key-value pair into the map. If the key already had a value
/// present in the map, that value is returned. Otherwise, `None` is returned.
///
/// *WARNING*: You should only use trusted values as keys in VecMap. Otherwise, a
/// denial-of-service vulnerability may occur that deplets memory with a large key value.
///
/// # Examples
///
/// ```
Expand Down Expand Up @@ -707,7 +710,7 @@ impl<'a, V, A: Allocator> Entry<'a, V, A> {
}

impl<'a, V, A: Allocator> VacantEntry<'a, V, A> {
/// Sets the value of the entry with the VacantEntry's key,
/// Sets the value of the entry with the `VacantEntry`'s key,
/// and returns a mutable reference to it.
pub fn insert(self, value: V) -> &'a mut V {
let index = self.index;
Expand Down Expand Up @@ -735,7 +738,7 @@ impl<'a, V, A: Allocator> OccupiedEntry<'a, V, A> {
&mut self.map[index]
}

/// Sets the value of the entry with the OccupiedEntry's key,
/// Sets the value of the entry with the `OccupiedEntry`'s key,
/// and returns the entry's old value.
pub fn insert(&mut self, value: V) -> V {
let index = self.index;
Expand Down Expand Up @@ -946,6 +949,7 @@ macro_rules! double_ended_iterator {
}

/// An iterator over the key-value pairs of a map.
#[derive(Clone)]
pub struct Iter<'a, V> {
front: usize,
back: usize,
Expand All @@ -954,19 +958,6 @@ pub struct Iter<'a, V> {
iter: slice::Iter<'a, Option<V>>,
}

// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
impl<'a, V> Clone for Iter<'a, V> {
fn clone(&self) -> Iter<'a, V> {
Iter {
front: self.front,
back: self.back,
n: self.n,
yielded: self.yielded,
iter: self.iter.clone(),
}
}
}

iterator! { impl Iter -> (usize, &'a V), as_ref }
impl<'a, V> ExactSizeIterator for Iter<'a, V> {}
double_ended_iterator! { impl Iter -> (usize, &'a V), as_ref }
Expand All @@ -986,33 +977,17 @@ impl<'a, V> ExactSizeIterator for IterMut<'a, V> {}
double_ended_iterator! { impl IterMut -> (usize, &'a mut V), as_mut }

/// An iterator over the keys of a map.
#[derive(Clone)]
pub struct Keys<'a, V> {
iter: Iter<'a, V>,
}

// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
impl<'a, V> Clone for Keys<'a, V> {
fn clone(&self) -> Keys<'a, V> {
Keys {
iter: self.iter.clone(),
}
}
}

/// An iterator over the values of a map.
#[derive(Clone)]
pub struct Values<'a, V> {
iter: Iter<'a, V>,
}

// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
impl<'a, V> Clone for Values<'a, V> {
fn clone(&self) -> Values<'a, V> {
Values {
iter: self.iter.clone(),
}
}
}

/// An iterator over the values of a map.
pub struct ValuesMut<'a, V> {
iter_mut: IterMut<'a, V>,
Expand Down

0 comments on commit c669b1f

Please sign in to comment.