Skip to content

Commit

Permalink
Restrict the dependency on indexmap to v2 only (#51)
Browse files Browse the repository at this point in the history
Allowing both indexmap v1 & v2 causes a lot of annoyance when the
version of indexmap used by this crate and the one used by other crates
in the dependency tree don't match.

See also yewstack/yew#3659
  • Loading branch information
its-the-shrimp authored Jul 12, 2024
1 parent 967ccac commit 14f4da6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 20 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ jobs:
rust:
- stable
- 1.64.0
indexmap:
- 1.9.3
- latest
include:
- os: ubuntu-latest
rust: stable
Expand All @@ -44,11 +41,6 @@ jobs:
default: true
override: true

- name: Change indexmap version
if: matrix.indexmap != 'latest'
run: |
cargo update -p indexmap --precise ${{ matrix.indexmap }}
- name: cargo test
uses: actions-rs/cargo@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ derive = ["implicit-clone-derive"]

[dependencies]
implicit-clone-derive = { version = "0.1", optional = true, path = "./implicit-clone-derive" }
indexmap = { version = ">= 1, <= 2", optional = true }
indexmap = { version = "2", optional = true }
serde = { version = "1", optional = true }

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion implicit-clone-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ syn = { version = "2", features = ["full"] }

[dev-dependencies]
implicit-clone = { path = ".." }
trybuild = "1"
trybuild = "=1.0.89"
rustversion = "1"
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ mod test {
#[test]
fn custom() {
#[derive(Clone)]
#[allow(dead_code)]
struct ImplicitCloneType;

impl ImplicitClone for ImplicitCloneType {}
Expand Down
20 changes: 10 additions & 10 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'sta
///
/// Computes in **O(1)** time (average).
#[inline]
pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<V>
pub fn get<Q>(&self, key: &Q) -> Option<V>
where
K: Borrow<Q>,
Q: Hash + Eq,
Q: Hash + Eq + ?Sized,
{
match self {
Self::Static(a) => a
Expand All @@ -181,10 +181,10 @@ impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'sta
///
/// Computes in **O(1)** time (average).
#[inline]
pub fn get_key_value<Q: ?Sized>(&self, key: &Q) -> Option<(K, V)>
pub fn get_key_value<Q>(&self, key: &Q) -> Option<(K, V)>
where
K: Borrow<Q>,
Q: Hash + Eq,
Q: Hash + Eq + ?Sized,
{
match self {
Self::Static(a) => a.iter().find(|(k, _)| k.borrow() == key).cloned(),
Expand All @@ -194,10 +194,10 @@ impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'sta

/// Return item index, key and value
#[inline]
pub fn get_full<Q: ?Sized>(&self, key: &Q) -> Option<(usize, K, V)>
pub fn get_full<Q>(&self, key: &Q) -> Option<(usize, K, V)>
where
K: Borrow<Q>,
Q: Hash + Eq,
Q: Hash + Eq + ?Sized,
{
match self {
Self::Static(a) => a
Expand Down Expand Up @@ -225,10 +225,10 @@ impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'sta
///
/// Computes in **O(1)** time (average).
#[inline]
pub fn get_index_of<Q: ?Sized>(&self, key: &Q) -> Option<usize>
pub fn get_index_of<Q>(&self, key: &Q) -> Option<usize>
where
K: Borrow<Q>,
Q: Hash + Eq,
Q: Hash + Eq + ?Sized,
{
match self {
Self::Static(a) => a
Expand All @@ -243,10 +243,10 @@ impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'sta
///
/// Computes in **O(1)** time (average).
#[inline]
pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool
pub fn contains_key<Q>(&self, key: &Q) -> bool
where
K: Borrow<Q>,
Q: Hash + Eq,
Q: Hash + Eq + ?Sized,
{
match self {
Self::Static(a) => a.iter().any(|(k, _)| k.borrow() == key),
Expand Down

0 comments on commit 14f4da6

Please sign in to comment.