Skip to content
Open
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
18 changes: 8 additions & 10 deletions src/btree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ pub struct BiBTreeMap<L, R> {
right2left: BTreeMap<Ref<R>, Ref<L>>,
}

impl<L, R> BiBTreeMap<L, R>
where
L: Ord,
R: Ord,
{
impl<L, R> BiBTreeMap<L, R> {
/// Creates an empty `BiBTreeMap`.
///
/// # Examples
Expand Down Expand Up @@ -177,7 +173,13 @@ where
inner: self.right2left.iter(),
}
}
}

impl<L, R> BiBTreeMap<L, R>
where
L: Ord,
R: Ord,
{
/// Returns a reference to the right value corresponding to the given left
/// value.
///
Expand Down Expand Up @@ -610,11 +612,7 @@ where
}
}

impl<L, R> Default for BiBTreeMap<L, R>
where
L: Ord,
R: Ord,
{
impl<L, R> Default for BiBTreeMap<L, R> {
fn default() -> BiBTreeMap<L, R> {
BiBTreeMap {
left2right: BTreeMap::default(),
Expand Down
28 changes: 12 additions & 16 deletions src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ pub struct BiHashMap<L, R, LS = hash_map::RandomState, RS = hash_map::RandomStat
right2left: HashMap<Ref<R>, Ref<L>, RS>,
}

impl<L, R> BiHashMap<L, R, hash_map::RandomState, hash_map::RandomState>
where
L: Eq + Hash,
R: Eq + Hash,
{
impl<L, R> BiHashMap<L, R, hash_map::RandomState, hash_map::RandomState> {
/// Creates an empty `BiHashMap`.
///
/// # Examples
Expand Down Expand Up @@ -62,11 +58,7 @@ where
}
}

impl<L, R, LS, RS> BiHashMap<L, R, LS, RS>
where
L: Eq + Hash,
R: Eq + Hash,
{
impl<L, R, LS, RS> BiHashMap<L, R, LS, RS> {
/// Returns the number of left-right pairs in the bimap.
///
/// # Examples
Expand Down Expand Up @@ -215,8 +207,6 @@ where

impl<L, R, LS, RS> BiHashMap<L, R, LS, RS>
where
L: Eq + Hash,
R: Eq + Hash,
LS: BuildHasher,
RS: BuildHasher,
{
Expand Down Expand Up @@ -266,7 +256,15 @@ where
right2left: HashMap::with_capacity_and_hasher(capacity, hash_builder_right),
}
}
}

impl<L, R, LS, RS> BiHashMap<L, R, LS, RS>
where
L: Eq + Hash,
R: Eq + Hash,
LS: BuildHasher,
RS: BuildHasher,
{
/// Reserves capacity for at least `additional` more elements to be inserted
/// in the `BiHashMap`. The collection may reserve more space to avoid
/// frequent reallocations.
Expand Down Expand Up @@ -699,10 +697,8 @@ where

impl<L, R, LS, RS> Default for BiHashMap<L, R, LS, RS>
where
L: Eq + Hash,
R: Eq + Hash,
LS: BuildHasher + Default,
RS: BuildHasher + Default,
LS: Default,
RS: Default,
{
fn default() -> BiHashMap<L, R, LS, RS> {
BiHashMap {
Expand Down