Impl Borrow<str> for MetaData for Records

so that we can use `&str` to query `BTreeSet<MetaData>`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-07-27 22:25:36 +10:00
parent aba2c87d6d
commit 04f167491a
No known key found for this signature in database
GPG key ID: 591C0B03040416D6

View file

@ -1,5 +1,5 @@
use std::{ use std::{
cmp, borrow, cmp,
collections::{btree_set, BTreeSet}, collections::{btree_set, BTreeSet},
fs, hash, fs, hash,
io::{self, Write}, io::{self, Write},
@ -25,6 +25,13 @@ pub struct MetaData {
pub target: CompactString, pub target: CompactString,
pub bins: Vec<CompactString>, pub bins: Vec<CompactString>,
} }
impl borrow::Borrow<str> for MetaData {
fn borrow(&self) -> &str {
&self.name
}
}
impl PartialEq for MetaData { impl PartialEq for MetaData {
fn eq(&self, other: &Self) -> bool { fn eq(&self, other: &Self) -> bool {
self.name == other.name self.name == other.name