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

Commit 0ce906a

Browse files
committed
replace .ok().expect() on results with .expect()
1 parent 20c1ffc commit 0ce906a

File tree

13 files changed

+119
-119
lines changed

13 files changed

+119
-119
lines changed

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)