Skip to content

Commit

Permalink
Ported to compile in rust 2018.
Browse files Browse the repository at this point in the history
Note that `tools/check.sh` does not pass yet because of these bugs:

  * rust-lang/cargo#5906
  * rust-lang/rustfmt#2927
  • Loading branch information
orium committed Aug 18, 2018
1 parent 68af21a commit 15f4a5e
Show file tree
Hide file tree
Showing 30 changed files with 137 additions and 157 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
cargo-features = ["edition"]

[package]
name = "rpds"
description = "Persistent data structures with structural sharing"
version = "0.5.0"
authors = ["Diogo Sousa <diogogsousa@gmail.com>"]

edition = "2018"

homepage = "https://github.com/orium/rpds"
repository = "https://github.com/orium/rpds"
documentation = "https://docs.rs/rpds"
Expand Down
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ To use rpds add the following to your `Cargo.toml`:
rpds = "<version>"
```

Additionally, add this to your crate root:

```rust,ignore
#[macro_use]
extern crate rpds;
```

## Data Structures

This crate offers the following data structures:
Expand Down
9 changes: 4 additions & 5 deletions benches/rpds_hash_trie_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
* 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/.
*/

#![feature(uniform_paths)]
#![cfg_attr(feature = "fatal-warnings", deny(warnings))]

#[macro_use]
extern crate criterion;
extern crate rpds;

mod utils;

use criterion::{black_box, Criterion};
use rpds::HashTrieMap;
use utils::limit;
use ::criterion::{black_box, Criterion, criterion_main, criterion_group};
use ::rpds::HashTrieMap;
use crate::utils::limit;

fn rpds_hash_trie_map_insert(c: &mut Criterion) {
let limit = limit(10_000);
Expand Down
9 changes: 4 additions & 5 deletions benches/rpds_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
* 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/.
*/

#![feature(uniform_paths)]
#![cfg_attr(feature = "fatal-warnings", deny(warnings))]

#[macro_use]
extern crate criterion;
extern crate rpds;

mod utils;

use criterion::{black_box, Criterion};
use rpds::List;
use utils::limit;
use ::criterion::{black_box, Criterion, criterion_main, criterion_group};
use ::rpds::List;
use crate::utils::limit;

fn rpds_list_push_front(c: &mut Criterion) {
let limit = limit(10_000);
Expand Down
9 changes: 4 additions & 5 deletions benches/rpds_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
* 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/.
*/

#![feature(uniform_paths)]
#![cfg_attr(feature = "fatal-warnings", deny(warnings))]

#[macro_use]
extern crate criterion;
extern crate rpds;

mod utils;

use criterion::{black_box, Criterion};
use rpds::Queue;
use utils::limit;
use ::criterion::{black_box, Criterion, criterion_main, criterion_group};
use ::rpds::Queue;
use crate::utils::limit;

fn rpds_queue_enqueue(c: &mut Criterion) {
let limit = limit(10_000);
Expand Down
9 changes: 4 additions & 5 deletions benches/rpds_red_black_tree_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
* 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/.
*/

#![feature(uniform_paths)]
#![cfg_attr(feature = "fatal-warnings", deny(warnings))]

#[macro_use]
extern crate criterion;
extern crate rpds;

mod utils;

use criterion::{black_box, Criterion};
use rpds::RedBlackTreeMap;
use utils::limit;
use ::criterion::{black_box, Criterion, criterion_main, criterion_group};
use ::rpds::RedBlackTreeMap;
use crate::utils::limit;

fn rpds_red_black_tree_map_insert(c: &mut Criterion) {
let limit = limit(10_000);
Expand Down
9 changes: 4 additions & 5 deletions benches/rpds_vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
* 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/.
*/

#![feature(uniform_paths)]
#![cfg_attr(feature = "fatal-warnings", deny(warnings))]

#[macro_use]
extern crate criterion;
extern crate rpds;

mod utils;

use criterion::{black_box, Criterion};
use rpds::Vector;
use utils::limit;
use ::criterion::{black_box, Criterion, criterion_main, criterion_group};
use ::rpds::Vector;
use crate::utils::limit;

fn rpds_vector_push_back(c: &mut Criterion) {
let limit = limit(10_000);
Expand Down
7 changes: 3 additions & 4 deletions benches/std_btree_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
* 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/.
*/

#![feature(uniform_paths)]
#![cfg_attr(feature = "fatal-warnings", deny(warnings))]

#[macro_use]
extern crate criterion;

mod utils;

use criterion::{black_box, Criterion};
use ::criterion::{black_box, Criterion, criterion_main, criterion_group};
use std::collections::BTreeMap;
use utils::limit;
use crate::utils::limit;

fn std_btree_map_insert(c: &mut Criterion) {
let limit = limit(10_000);
Expand Down
7 changes: 3 additions & 4 deletions benches/std_hash_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
* 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/.
*/

#![feature(uniform_paths)]
#![cfg_attr(feature = "fatal-warnings", deny(warnings))]

#[macro_use]
extern crate criterion;

mod utils;

use criterion::{black_box, Criterion};
use ::criterion::{black_box, Criterion, criterion_main, criterion_group};
use std::collections::HashMap;
use utils::limit;
use crate::utils::limit;

fn std_hash_map_insert(c: &mut Criterion) {
let limit = limit(10_000);
Expand Down
7 changes: 3 additions & 4 deletions benches/std_linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
* 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/.
*/

#![feature(uniform_paths)]
#![cfg_attr(feature = "fatal-warnings", deny(warnings))]

#[macro_use]
extern crate criterion;

mod utils;

use criterion::{black_box, Criterion};
use ::criterion::{black_box, Criterion, criterion_main, criterion_group};
use std::collections::LinkedList;
use utils::limit;
use crate::utils::limit;

fn std_linked_list_push_front(c: &mut Criterion) {
let limit = limit(10_000);
Expand Down
7 changes: 3 additions & 4 deletions benches/std_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
* 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/.
*/

#![feature(uniform_paths)]
#![cfg_attr(feature = "fatal-warnings", deny(warnings))]

#[macro_use]
extern crate criterion;

mod utils;

use criterion::{black_box, Criterion};
use utils::limit;
use ::criterion::{black_box, Criterion, criterion_main, criterion_group};
use crate::utils::limit;

fn std_vec_push(c: &mut Criterion) {
let limit = limit(10_000);
Expand Down
7 changes: 3 additions & 4 deletions benches/std_vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
* 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/.
*/

#![feature(uniform_paths)]
#![cfg_attr(feature = "fatal-warnings", deny(warnings))]

#[macro_use]
extern crate criterion;

mod utils;

use criterion::{black_box, Criterion};
use ::criterion::{black_box, Criterion, criterion_main, criterion_group};
use std::collections::VecDeque;
use utils::limit;
use crate::utils::limit;

fn std_vec_dequeue_push_back(c: &mut Criterion) {
let limit = limit(10_000);
Expand Down
25 changes: 9 additions & 16 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* 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/.
*/
#![feature(uniform_paths)]

#![cfg_attr(feature = "fatal-warnings", deny(warnings))]
#![cfg_attr(feature = "cargo-clippy", allow(match_bool))]
Expand All @@ -20,13 +21,6 @@
//! rpds = "<version>"
//! ```
//!
//! Additionally, add this to your crate root:
//!
//! ```rust,ignore
//! #[macro_use]
//! extern crate rpds;
//! ```
//!
//! ## Data Structures
//!
//! This crate offers the following data structures:
Expand Down Expand Up @@ -294,7 +288,6 @@ extern crate serde;
extern crate bincode;

#[cfg(test)]
#[macro_use]
extern crate pretty_assertions;

mod utils;
Expand All @@ -306,11 +299,11 @@ pub mod set;
pub mod stack;
pub mod vector;

pub use list::List;
pub use map::hash_trie_map::HashTrieMap;
pub use map::red_black_tree_map::RedBlackTreeMap;
pub use queue::Queue;
pub use set::hash_trie_set::HashTrieSet;
pub use set::red_black_tree_set::RedBlackTreeSet;
pub use stack::Stack;
pub use vector::Vector;
pub use crate::list::List;
pub use crate::map::hash_trie_map::HashTrieMap;
pub use crate::map::red_black_tree_map::RedBlackTreeMap;
pub use crate::queue::Queue;
pub use crate::set::hash_trie_set::HashTrieSet;
pub use crate::set::red_black_tree_set::RedBlackTreeSet;
pub use crate::stack::Stack;
pub use crate::vector::Vector;
14 changes: 7 additions & 7 deletions src/list/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,11 @@ impl<T> List<T> {
}

#[must_use]
pub fn iter(&self) -> Iter<T> {
pub fn iter(&self) -> Iter<'_, T> {
self.iter_arc().map(|v| v.borrow())
}

pub(crate) fn iter_arc(&self) -> IterArc<T> {
pub(crate) fn iter_arc(&self) -> IterArc<'_, T> {
IterArc::new(self)
}
}
Expand Down Expand Up @@ -288,7 +288,7 @@ impl<T> Clone for List<T> {
}

impl<T: Display> Display for List<T> {
fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
let mut first = true;

fmt.write_str("[")?;
Expand Down Expand Up @@ -341,7 +341,7 @@ pub struct IterArc<'a, T: 'a> {
}

impl<'a, T> IterArc<'a, T> {
fn new(list: &List<T>) -> IterArc<T> {
fn new(list: &List<T>) -> IterArc<'_, T> {
IterArc {
next: list.head.as_ref().map(|node| node.as_ref()),
length: list.len(),
Expand Down Expand Up @@ -376,8 +376,8 @@ impl<'a, T> ExactSizeIterator for IterArc<'a, T> {}
#[cfg(feature = "serde")]
pub mod serde {
use super::*;
use serde::de::{Deserialize, Deserializer, SeqAccess, Visitor};
use serde::ser::{Serialize, Serializer};
use ::serde::de::{Deserialize, Deserializer, SeqAccess, Visitor};
use ::serde::ser::{Serialize, Serializer};
use std::fmt;
use std::marker::PhantomData;

Expand Down Expand Up @@ -411,7 +411,7 @@ pub mod serde {
{
type Value = List<T>;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("a sequence")
}

Expand Down
4 changes: 2 additions & 2 deletions src/list/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ mod compile_time {

#[test]
fn test_is_send() {
let _: Box<Send> = Box::new(List::<i32>::new());
let _: Box<dyn Send> = Box::new(List::<i32>::new());
}

#[test]
fn test_is_sync() {
let _: Box<Sync> = Box::new(List::<i32>::new());
let _: Box<dyn Sync> = Box::new(List::<i32>::new());
}
}

Expand Down
Loading

0 comments on commit 15f4a5e

Please sign in to comment.