Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use mod paths instead of include #33

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/array.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
use std::fmt;

use super::Rc;
use crate::ImplicitClone;

/// An immutable array type inspired by [Immutable.js](https://immutable-js.com/).
///
/// This type is cheap to clone and thus implements [`ImplicitClone`]. It can be created based on a
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![warn(missing_debug_implementations, missing_docs, unreachable_pub)]
#![allow(clippy::unnecessary_lazy_evaluations)]
#![allow(clippy::duplicate_mod)]
#![doc(test(
no_crate_inject,
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
Expand Down
8 changes: 7 additions & 1 deletion src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ use indexmap::map::Keys as MapKeys;
use indexmap::map::Values as MapValues;
use indexmap::IndexMap as Map;
use std::borrow::Borrow;
use std::fmt;
use std::hash::Hash;

use crate::ImplicitClone;

use super::IString;
use super::Rc;

/// An immutable hash map type inspired by [Immutable.js](https://immutable-js.com/).
///
/// This type is cheap to clone and thus implements [`ImplicitClone`]. It can be created based on a
Expand Down Expand Up @@ -346,7 +352,7 @@ where
for (k, v) in a.iter() {
seq.serialize_entry(k, v)?;
}
},
}
Self::Rc(a) => {
for (k, v) in a.iter() {
seq.serialize_entry(k, v)?;
Expand Down
6 changes: 5 additions & 1 deletion src/string.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
use std::borrow::Cow;
use std::cmp::Ordering;
use std::fmt::Debug;
use std::fmt::{self, Debug};
use std::str::FromStr;

use crate::ImplicitClone;

use super::Rc;

/// An immutable string type inspired by [Immutable.js](https://immutable-js.com/).
///
/// This type is cheap to clone and thus implements [`ImplicitClone`]. It can be created based on a
Expand Down
17 changes: 12 additions & 5 deletions src/sync.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
use std::sync::Arc as Rc;

use crate::ImplicitClone;
use std::fmt;

type Rc<T> = std::sync::Arc<T>;
#[path = "array.rs"]
mod array;
#[cfg(feature = "map")]
#[path = "map.rs"]
mod map;
#[path = "string.rs"]
mod string;

include!("string.rs");
include!("array.rs");
pub use array::IArray;
#[cfg(feature = "map")]
include!("map.rs");
pub use map::IMap;
pub use string::IString;

impl<T: ?Sized> ImplicitClone for Rc<T> {}
18 changes: 13 additions & 5 deletions src/unsync.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
use crate::ImplicitClone;
use std::fmt;
use std::rc::Rc;

include!("string.rs");
include!("array.rs");
use crate::ImplicitClone;

#[path = "array.rs"]
mod array;
#[cfg(feature = "map")]
#[path = "map.rs"]
mod map;
#[path = "string.rs"]
mod string;

pub use array::IArray;
#[cfg(feature = "map")]
include!("map.rs");
pub use map::IMap;
pub use string::IString;

impl<T: ?Sized> ImplicitClone for Rc<T> {}
Loading