Skip to content

Commit 67d08ef

Browse files
authored
RUST-1076 Remove conditional module definition (#511)
1 parent 8e55cb2 commit 67d08ef

File tree

3 files changed

+46
-64
lines changed

3 files changed

+46
-64
lines changed

src/client/options/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,7 @@ impl ClientOptionsParser {
14791479
credential.source = options
14801480
.auth_source
14811481
.clone()
1482-
.or(db.clone())
1482+
.or_else(|| db.clone())
14831483
.or_else(|| Some("admin".into()));
14841484
} else if authentication_requested {
14851485
return Err(ErrorKind::InvalidArgument {

src/lib.rs

Lines changed: 45 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -304,73 +304,57 @@
304304
#[cfg(all(feature = "aws-auth", feature = "async-std-runtime"))]
305305
compile_error!("The `aws-auth` feature flag is only supported on the tokio runtime.");
306306

307-
macro_rules! define_if_single_runtime_enabled {
308-
( $( $def:item )+ ) => {
309-
$(
310-
#[cfg(any(
311-
all(feature = "tokio-runtime", not(feature = "async-std-runtime")),
312-
all(not(feature = "tokio-runtime"), feature = "async-std-runtime")
313-
))]
314-
$def
315-
)+
316-
}
317-
}
307+
#[macro_use]
308+
pub mod options;
318309

319-
// In the case that neither tokio nor async-std is enabled, we want to disable all compiler errors
320-
// and warnings other than our custom ones.
321-
define_if_single_runtime_enabled! {
322-
#[macro_use]
323-
pub mod options;
310+
pub use ::bson;
324311

325-
pub use ::bson;
312+
mod bson_util;
313+
mod client;
314+
mod cmap;
315+
mod coll;
316+
mod collation;
317+
mod compression;
318+
mod concern;
319+
mod cursor;
320+
mod db;
321+
pub mod error;
322+
pub mod event;
323+
mod index;
324+
mod is_master;
325+
mod operation;
326+
pub mod results;
327+
pub(crate) mod runtime;
328+
mod sdam;
329+
mod selection_criteria;
330+
mod srv;
331+
#[cfg(any(feature = "sync", docsrs))]
332+
#[cfg_attr(docsrs, doc(cfg(feature = "sync")))]
333+
pub mod sync;
334+
#[cfg(test)]
335+
mod test;
326336

327-
mod bson_util;
328-
mod client;
329-
mod cmap;
330-
mod coll;
331-
mod collation;
332-
mod compression;
333-
mod concern;
334-
mod cursor;
335-
mod db;
336-
pub mod error;
337-
pub mod event;
338-
mod index;
339-
mod is_master;
340-
mod operation;
341-
pub mod results;
342-
pub(crate) mod runtime;
343-
mod sdam;
344-
mod selection_criteria;
345-
mod srv;
346-
#[cfg(any(feature = "sync", docsrs))]
347-
#[cfg_attr(docsrs, doc(cfg(feature = "sync")))]
348-
pub mod sync;
349-
#[cfg(test)]
350-
mod test;
337+
#[cfg(test)]
338+
#[macro_use]
339+
extern crate derive_more;
351340

352-
#[cfg(test)]
353-
#[macro_use]
354-
extern crate derive_more;
341+
#[cfg(not(feature = "sync"))]
342+
pub use crate::{
343+
client::{Client, session::ClientSession},
344+
coll::Collection,
345+
cursor::{Cursor, session::{SessionCursor, SessionCursorStream}},
346+
db::Database,
347+
};
355348

356-
#[cfg(not(feature = "sync"))]
357-
pub use crate::{
358-
client::{Client, session::ClientSession},
359-
coll::Collection,
360-
cursor::{Cursor, session::{SessionCursor, SessionCursorStream}},
361-
db::Database,
362-
};
349+
#[cfg(feature = "sync")]
350+
pub(crate) use crate::{
351+
client::{Client, session::ClientSession},
352+
coll::Collection,
353+
cursor::{Cursor, session::{SessionCursor, SessionCursorStream}},
354+
db::Database,
355+
};
363356

364-
#[cfg(feature = "sync")]
365-
pub(crate) use crate::{
366-
client::{Client, session::ClientSession},
367-
coll::Collection,
368-
cursor::{Cursor, session::{SessionCursor, SessionCursorStream}},
369-
db::Database,
370-
};
371-
372-
pub use {coll::Namespace, index::IndexModel, client::session::ClusterTime};
373-
}
357+
pub use {coll::Namespace, index::IndexModel, client::session::ClusterTime};
374358

375359
#[cfg(all(
376360
feature = "tokio-runtime",

src/selection_criteria.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,6 @@ impl ReadPreference {
323323
where
324324
S: serde::Serializer,
325325
{
326-
use serde::ser::Serialize;
327-
328326
#[derive(serde::Serialize)]
329327
struct ReadPreferenceHelper<'a> {
330328
readpreference: &'a str,

0 commit comments

Comments
 (0)