Skip to content
This repository was archived by the owner on Oct 18, 2021. It is now read-only.

Commit 9b0468b

Browse files
committed
Merge pull request #127 from saghm/1.4
Some changes to reflect Rust 1.4 update
2 parents 42ee692 + 0ce906a commit 9b0468b

File tree

14 files changed

+136
-130
lines changed

14 files changed

+136
-130
lines changed

README.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,39 @@
1-
[![Travis](https://travis-ci.org/mongodb-labs/mongo-rust-driver-prototype.svg)](https://travis-ci.org/mongodb-labs/mongo-rust-driver-prototype)
2-
[![Crates.io](https://img.shields.io/crates/v/mongodb.svg)](https://crates.io/crates/mongodb)
3-
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
1+
[![Travis](https://travis-ci.org/mongodb-labs/mongo-rust-driver-prototype.svg)](https://travis-ci.org/mongodb-labs/mongo-rust-driver-prototype)[![Crates.io](https://img.shields.io/crates/v/mongodb.svg)](https://crates.io/crates/mongodb)[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
42

53
MongoDB Rust Driver Prototype
64
=============================
75

8-
This branch contains active development on a new driver written for Rust 1.0.
6+
This branch contains active development on a new driver written for Rust 1.x.
97

108
The API and implementation are currently subject to change at any time. You must not use this driver in production as it is still under development and is in no way supported by MongoDB Inc. We absolutely encourage you to experiment with it and provide us feedback on the API, design, and implementation. Bug reports and suggestions for improvements are welcomed, as are pull requests.
119

12-
## Installation
10+
Installation
11+
------------
1312

1413
#### Dependencies
15-
- [Rust 1.0 with Cargo](http://rust-lang.org)
14+
15+
- [Rust 1.x with Cargo](http://rust-lang.org)
1616

1717
#### Importing
18-
The 1.0 driver is available on crates.io. To use the MongoDB driver in your code, add the bson and mongodb packages to your ```Cargo.toml```:
18+
19+
The 1.0 driver is available on crates.io. To use the MongoDB driver in your code, add the bson and mongodb packages to your `Cargo.toml`:
20+
1921
```
2022
[dependencies]
21-
bson = "0.1.3"
23+
bson = "0.1.4"
2224
mongodb = "0.1.0"
2325
```
2426

2527
Then, import the bson and driver libraries within your code.
28+
2629
```rust
2730
#[macro_use(bson, doc)]
2831
extern crate bson;
2932
extern crate mongodb;
3033
```
3134

32-
## Examples
35+
Examples
36+
--------
3337

3438
Here's a basic example of driver usage:
3539

@@ -69,5 +73,7 @@ fn main() {
6973
}
7074
```
7175

72-
## Documentation
73-
Documentation is built using Cargo. The latest documentation can be found [here](https://mongodb-labs.github.io/mongo-rust-driver-prototype/mongodb). Generated documentation using ```cargo doc``` can be found under the _target/doc/_ folder.
76+
Documentation
77+
-------------
78+
79+
Documentation is built using Cargo. The latest documentation can be found [here](https://mongodb-labs.github.io/mongo-rust-driver-prototype/mongodb). Generated documentation using `cargo doc` can be found under the *target/doc/* folder.

src/cursor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//!
1717
//! let mut cursor = coll.find(None, None).unwrap();
1818
//! for result in cursor {
19-
//! let doc = result.ok().expect("Received network error during cursor operations.");
19+
//! let doc = result.expect("Received network error during cursor operations.");
2020
//! if let Some(&Bson::String(ref value)) = doc.get("spirit_animal") {
2121
//! println!("My spirit animal is {}", value);
2222
//! }

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212
//! #
1313
//! // Direct connection to a server. Will not look for other servers in the topology.
1414
//! let client = Client::connect("localhost", 27017)
15-
//! .ok().expect("Failed to initialize client.");
15+
//! .expect("Failed to initialize client.");
1616
//!
1717
//! // Connect to a complex server topology, such as a replica set
1818
//! // or sharded cluster, using a connection string uri.
1919
//! let client = Client::with_uri("mongodb://localhost:27017,localhost:27018/")
20-
//! .ok().expect("Failed to initialize client.");
20+
//! .expect("Failed to initialize client.");
2121
//!
2222
//! // Specify a read preference, and rely on the driver to find secondaries.
2323
//! let mut options = ClientOptions::new();
2424
//! options.read_preference = Some(ReadPreference::new(ReadMode::SecondaryPreferred, None));
2525
//! let client = Client::with_uri_and_options("mongodb://localhost:27017/", options)
26-
//! .ok().expect("Failed to initialize client.");
26+
//! .expect("Failed to initialize client.");
2727
//! ```
2828
//!
2929
//! ## Interacting with MongoDB Collections

tests/apm/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn timed_query(_client: Client, command_result: &CommandResult) {
2323

2424
#[test]
2525
fn command_duration() {
26-
let mut client = Client::connect("localhost", 27017).ok().expect("damn it!");
26+
let mut client = Client::connect("localhost", 27017).expect("damn it!");
2727
let db = client.db("test");
2828
let coll = db.collection("event_hooks");
2929
coll.drop().unwrap();

tests/client/client.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@ use std::thread;
66
#[test]
77
fn database_names() {
88
let client = Client::connect("localhost", 27018).unwrap();
9-
let state_results = client.database_names().ok().expect("Failed to execute database_names.");
9+
let state_results = client.database_names().expect("Failed to execute database_names.");
1010
for name in state_results {
1111
if name != "local" {
12-
client.drop_database(&name[..]).ok().expect("Failed to drop database from server.");
12+
client.drop_database(&name[..]).expect("Failed to drop database from server.");
1313
}
1414
}
1515

16-
let base_results = client.database_names().ok().expect("Failed to execute database_names.");
16+
let base_results = client.database_names().expect("Failed to execute database_names.");
1717
assert_eq!(1, base_results.len());
1818
assert_eq!("local", base_results[0]);
1919

2020
// Build dbs
2121
let db1 = client.db("new_db");
2222
let db2 = client.db("new_db_2");
2323
db1.collection("test1").insert_one(bson::Document::new(), None)
24-
.ok().expect("Failed to insert placeholder document into collection");
24+
.expect("Failed to insert placeholder document into collection");
2525
db2.collection("test2").insert_one(bson::Document::new(), None)
26-
.ok().expect("Failed to insert placeholder document into collection");
26+
.expect("Failed to insert placeholder document into collection");
2727

2828
// Check new dbs
29-
let results = client.database_names().ok().expect("Failed to execute database_names.");
29+
let results = client.database_names().expect("Failed to execute database_names.");
3030
assert_eq!(3, results.len());
3131
assert!(results.contains(&"local".to_owned()));
3232
assert!(results.contains(&"new_db".to_owned()));
@@ -37,48 +37,48 @@ fn database_names() {
3737
#[test]
3838
fn is_master() {
3939
let client = Client::connect("localhost", 27017).unwrap();
40-
let res = client.is_master().ok().expect("Failed to execute is_master.");
40+
let res = client.is_master().expect("Failed to execute is_master.");
4141
assert!(res);
4242
}
4343

4444
#[test]
4545
fn is_sync() {
4646
let client = Client::connect("localhost", 27018).unwrap();
47-
let state_results = client.database_names().ok().expect("Failed to execute database_names.");
47+
let state_results = client.database_names().expect("Failed to execute database_names.");
4848
for name in state_results {
4949
if name != "local" {
50-
client.drop_database(&name[..]).ok().expect("Failed to drop database from server.");
50+
client.drop_database(&name[..]).expect("Failed to drop database from server.");
5151
}
5252
}
5353

5454
let client1 = client.clone();
5555
let client2 = client.clone();
5656

57-
let base_results = client.database_names().ok().expect("Failed to execute database_names.");
57+
let base_results = client.database_names().expect("Failed to execute database_names.");
5858
assert_eq!(1, base_results.len());
5959
assert_eq!("local", base_results[0]);
6060

6161
let child1 = thread::spawn(move || {
6262
let db = client1.db("concurrent_db");
6363
db.collection("test1").insert_one(bson::Document::new(), None)
64-
.ok().expect("Failed to insert placeholder document into collection");
65-
let results = client1.database_names().ok().expect("Failed to execute database_names.");
64+
.expect("Failed to insert placeholder document into collection");
65+
let results = client1.database_names().expect("Failed to execute database_names.");
6666
assert!(results.contains(&"concurrent_db".to_owned()));
6767
});
6868

6969
let child2 = thread::spawn(move || {
7070
let db = client2.db("concurrent_db_2");
7171
db.collection("test2").insert_one(bson::Document::new(), None)
72-
.ok().expect("Failed to insert placeholder document into collection");
73-
let results = client2.database_names().ok().expect("Failed to execute database_names.");
72+
.expect("Failed to insert placeholder document into collection");
73+
let results = client2.database_names().expect("Failed to execute database_names.");
7474
assert!(results.contains(&"concurrent_db_2".to_owned()));
7575
});
7676

7777
let _ = child1.join();
7878
let _ = child2.join();
7979

8080
// Check new dbs
81-
let results = client.database_names().ok().expect("Failed to execute database_names.");
81+
let results = client.database_names().expect("Failed to execute database_names.");
8282
assert_eq!(3, results.len());
8383
assert!(results.contains(&"local".to_owned()));
8484
assert!(results.contains(&"concurrent_db".to_owned()));

0 commit comments

Comments
 (0)