Skip to content

Latest commit

 

History

History
27 lines (19 loc) · 574 Bytes

README.md

File metadata and controls

27 lines (19 loc) · 574 Bytes

Example: implementing Borrow for complex keys

This repository contains a working Rust example for how to implement Borrow for non-trivial keys, written in a literate programming style.

Given, for example:

struct OwnedKey {
    s: String,
    bytes: Vec<u8>,
}

struct BorrowedKey<'a> {
    s: &'a str,
    bytes: &'a [u8],
}

how can you use BorrowedKey instances to do lookups for a HashSet<OwnedKey> or BTreeSet<OwnedKey>?

Head on over to src/lib.rs to find out!

License

CC0: https://creativecommons.org/publicdomain/zero/1.0/