Skip to content

Commit

Permalink
Updated README.md to mention mutable methods and initialization mac…
Browse files Browse the repository at this point in the history
…ros.

Fixes #14.
  • Loading branch information
orium committed Apr 12, 2018
1 parent 3a787f9 commit d44e715
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 24 deletions.
56 changes: 44 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,9 @@ Additionally, add this to your crate root:
extern crate rpds;
```

### Enable serialization

To enable serialization (using [serde](https://crates.io/crates/serde)) you need to enable the
`serde` feature in rpds. To do so change the rpds dependency in `Cargo.toml` to

```toml
[dependencies]
rpds = { version = "<version>", features = ["serde"] }
```

## Data Structures

This crate implements the following data structures:
This crate offers the following data structures:

1. [`List`](#list)
2. [`Vector`](#vector)
Expand Down Expand Up @@ -84,7 +74,7 @@ and [Understanding Persistent Vector Part 2](http://hypirion.com/musings/underst
use rpds::Vector;

let vector = Vector::new()
.push_back("I'm")
.push_back("Im")
.push_back("a")
.push_back("vector");

Expand Down Expand Up @@ -245,3 +235,45 @@ assert!(!set_positive.contains(&"zero"));

assert_eq!(set_positive.first(), Some(&"one"));
```

## Other Features

### Mutable Methods

When you change a data structure you often do not need its previous versions. For those cases
rpds offers you mutable methods which are generally faster:

```rust
use rpds::HashTrieSet;

let mut set = HashTrieSet::new();

set.insert_mut("zero");
set.insert_mut("one");

let set_0_1 = set.clone();
let set_0_1_2 = set.insert("two");
```

### Initialization Macros

There are convenient initialization macros for all data structures:

```rust
use rpds::*;

let vector = vector![3, 1, 4, 1, 5];
let map = ht_map!["orange" => "orange", "banana" => "yellow"];
```

Check the documentation for initialization macros of other data structures.

### Serialization

We support serialization through [serde](https://crates.io/crates/serde). To use it
enable the `serde` feature. To do so change the rpds dependency in your `Cargo.toml` to

```toml
[dependencies]
rpds = { version = "<version>", features = ["serde"] }
```
56 changes: 44 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,9 @@
//! extern crate rpds;
//! ```
//!
//! ### Enable serialization
//!
//! To enable serialization (using [serde](https://crates.io/crates/serde)) you need to enable the
//! `serde` feature in rpds. To do so change the rpds dependency in `Cargo.toml` to
//!
//! ```toml
//! [dependencies]
//! rpds = { version = "<version>", features = ["serde"] }
//! ```
//!
//! ## Data Structures
//!
//! This crate implements the following data structures:
//! This crate offers the following data structures:
//!
//! 1. [`List`](#list)
//! 2. [`Vector`](#vector)
Expand Down Expand Up @@ -87,7 +77,7 @@
//! use rpds::Vector;
//!
//! let vector = Vector::new()
//! .push_back("I'm")
//! .push_back("Im")
//! .push_back("a")
//! .push_back("vector");
//!
Expand Down Expand Up @@ -254,6 +244,48 @@
//!
//! assert_eq!(set_positive.first(), Some(&"one"));
//! ```
//!
//! ## Other Features
//!
//! ### Mutable Methods
//!
//! When you change a data structure you often do not need its previous versions. For those cases
//! rpds offers you mutable methods which are generally faster:
//!
//! ```rust
//! use rpds::HashTrieSet;
//!
//! let mut set = HashTrieSet::new();
//!
//! set.insert_mut("zero");
//! set.insert_mut("one");
//!
//! let set_0_1 = set.clone();
//! let set_0_1_2 = set.insert("two");
//! ```
//!
//! ### Initialization Macros
//!
//! There are convenient initialization macros for all data structures:
//!
//! ```rust
//! use rpds::*;
//!
//! let vector = vector![3, 1, 4, 1, 5];
//! let map = ht_map!["orange" => "orange", "banana" => "yellow"];
//! ```
//!
//! Check the documentation for initialization macros of other data structures.
//!
//! ### Serialization
//!
//! We support serialization through [serde](https://crates.io/crates/serde). To use it
//! enable the `serde` feature. To do so change the rpds dependency in your `Cargo.toml` to
//!
//! ```toml
//! [dependencies]
//! rpds = { version = "<version>", features = ["serde"] }
//! ```

#[cfg(feature = "serde")]
extern crate serde;
Expand Down

0 comments on commit d44e715

Please sign in to comment.