From 04f167491aa452bc6d597fe564bfa8e62710eaae Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Wed, 27 Jul 2022 22:25:36 +1000 Subject: [PATCH] Impl `Borrow` for `MetaData` for `Records` so that we can use `&str` to query `BTreeSet` Signed-off-by: Jiahao XU --- src/metafiles/binstall_v1.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/metafiles/binstall_v1.rs b/src/metafiles/binstall_v1.rs index 5d2d6e06..edb9c61c 100644 --- a/src/metafiles/binstall_v1.rs +++ b/src/metafiles/binstall_v1.rs @@ -1,5 +1,5 @@ use std::{ - cmp, + borrow, cmp, collections::{btree_set, BTreeSet}, fs, hash, io::{self, Write}, @@ -25,6 +25,13 @@ pub struct MetaData { pub target: CompactString, pub bins: Vec, } + +impl borrow::Borrow for MetaData { + fn borrow(&self) -> &str { + &self.name + } +} + impl PartialEq for MetaData { fn eq(&self, other: &Self) -> bool { self.name == other.name