From 1787ff3546874f67c1ea51b38c74e18d427d9594 Mon Sep 17 00:00:00 2001 From: Avril Date: Mon, 19 Oct 2020 17:14:19 +0100 Subject: [PATCH] readme --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..7af2e23 --- /dev/null +++ b/README.md @@ -0,0 +1,30 @@ +# refset - non-owning `HsahSet` + +A hash-set analogue that does not own its data. + +It can be used to "mark" items without the need to transfer ownership to the map + +# Example use case + ```rust + /// Process arguments while ignoring duplicates + fn process_args(args: impl IntoIterator) { + let mut same= HashRefSet::new(); + for argument in args.into_iter() + { + if !same.insert(argument.as_str()) { + // Already processed this input, ignore + continue; + } + //do work... + } + } + ``` +# Serialisation support with `serde` crate + `HashRefSet` and `HashType` both implement `Serialize` and `Deserialize` from the `serde` crate if the `serde` feature is enabled. By default it is not. + +# Drawbacks + Since the item is not inserted itself, we cannot use `Eq` to double check there was not a hash collision. + While the hashing algorithm used (Sha512) is extremely unlikely to produce collisions, especially for small data types, keep in mind that it is not infallible. + +# License +MIT