Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Merge branch 'fitzgen:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Cobrand authored Aug 18, 2023
2 parents 8e584d7 + 6dbc29e commit 736bc70
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.2.9

Released 2023-05-22.

# 0.2.8

Released 2020-05-18.
Expand Down
13 changes: 10 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@ license = "MPL-2.0"
name = "generational-arena"
readme = "./README.md"
repository = "https://github.com/fitzgen/generational-arena"
version = "0.2.8"
version = "0.2.9"
edition = "2018"

[badges]
travis-ci = { repository = "fitzgen/generational-arena" }
# The following notice applies to all the files in this source tree:
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# (If you copy files from this project into another program which is not
# licenced MPL-2.0, you should add that notice to each copied file.)

[dependencies]
cfg-if = "1.0.0"
Expand All @@ -21,6 +27,7 @@ serde = { version = "1.0.102", optional = true, default-features = false }
quickcheck = "0.9.0"
criterion = "0.3.0"
serde_test = "1.0.102"
serde_yaml = "0.8.13"
bincode = "1.2.0"
serde = { version = "1.0.102", default-features = false, features = ["derive"] }

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![](https://docs.rs/generational-arena/badge.svg)](https://docs.rs/generational-arena/)
[![](https://img.shields.io/crates/v/generational-arena.svg)](https://crates.io/crates/generational-arena)
[![](https://img.shields.io/crates/d/generational-arena.svg)](https://crates.io/crates/generational-arena)
[![Travis CI Build Status](https://travis-ci.org/fitzgen/generational-arena.svg?branch=master)](https://travis-ci.org/fitzgen/generational-arena)
[![](https://github.com/fitzgen/generational-arena/actions/workflows/rust.yml/badge.svg)](https://github.com/fitzgen/generational-arena/actions/workflows/rust.yml)

A safe arena allocator that allows deletion without suffering from [the ABA
problem](https://en.wikipedia.org/wiki/ABA_problem) by using generational
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![](https://docs.rs/generational-arena/badge.svg)](https://docs.rs/generational-arena/)
[![](https://img.shields.io/crates/v/generational-arena.svg)](https://crates.io/crates/generational-arena)
[![](https://img.shields.io/crates/d/generational-arena.svg)](https://crates.io/crates/generational-arena)
[![Travis CI Build Status](https://travis-ci.org/fitzgen/generational-arena.svg?branch=master)](https://travis-ci.org/fitzgen/generational-arena)
[![](https://github.com/fitzgen/generational-arena/actions/workflows/rust.yml/badge.svg)](https://github.com/fitzgen/generational-arena/actions/workflows/rust.yml)
A safe arena allocator that allows deletion without suffering from [the ABA
problem](https://en.wikipedia.org/wiki/ABA_problem) by using generational
Expand Down
4 changes: 2 additions & 2 deletions src/serde_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ where
}

// items.len() must be same as item.capacity(), so fill the unused elements with Free.
if items.len() + 1 < items.capacity() {
let add_cap = items.capacity() - (items.len() + 1);
if items.len() < items.capacity() {
let add_cap = items.capacity() - items.len();
items.reserve_exact(add_cap);
items.extend(iter::repeat_with(|| Entry::Free { next_free: None }).take(add_cap));
debug_assert_eq!(items.len(), items.capacity());
Expand Down
12 changes: 12 additions & 0 deletions tests/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ extern crate serde_test;
use generational_arena::{Arena, Index};
use serde::{Deserialize, Serialize};
use serde_test::{assert_ser_tokens, Token};
use std::iter::FromIterator;
use std::fmt::Debug;

#[test]
Expand Down Expand Up @@ -139,6 +140,17 @@ fn fully_occupied_arena_can_be_serialized_and_deserialized() {
assert_tokens(&arena, &tokens);
}

#[test]
fn arena_from_iter_can_be_serialized_and_deserialized_without_panic() {

let mut vec = vec![0usize];
let x = vec.drain(..);
let mut arena_in = Arena::from_iter(x);

let ser = serde_yaml::to_string(&arena_in).unwrap();
let arena_out: Arena<usize> = serde_yaml::from_str(&ser).unwrap();
}

/// Arena wrapper struct for comparing two arenas
///
/// `serde_test::assert_tokens` requires the value implements `PartialEq`,
Expand Down

0 comments on commit 736bc70

Please sign in to comment.