equivalent-flipped 1.0.0

Similar to `equivalent` crate, but flips `K` and `Q`.
Documentation
  • Coverage
  • 100%
    7 out of 7 items documented0 out of 6 items with examples
  • Size
  • Source code size: 27.87 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 732.49 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • al8n/equivalent-flipped
    3 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • al8n

English | 简体中文

Inspired by indexmap-rs/equivalent, providing Equivalent and Comparable, which are Rust traits for key comparison in maps, but flips K and Q.

These may be used in the implementation of maps where the lookup type Q may be different than the stored key type K.

  • K: Equivalent<Q>, Q: ?Sized checks for equality, similar to the HashMap<K, V> constraint K: Borrow<Q>, Q: Eq.
  • K: Comparable<Q>, Q: ?Sized checks the ordering, similar to the BTreeMap<K, V> constraint K: Borrow<Q>, Q: Ord.

These traits are not used by the maps in the standard library, but they may add more flexibility in third-party map implementations, especially in situations where a strict K: Borrow<Q> relationship is not available.

Installation

[dependencies]
equivalent-flipped = "0.1"

Pedigree

This code is inspired and modified based on indexmap-rs/equivalent, and reference to @cuviper attempts on https://github.com/indexmap-rs/indexmap/issues/253#issuecomment-1459160166

License

equivalent-flipped is under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE, LICENSE-MIT for details.

Copyright (c) 2024 Al Liu.