sunshowers-code/borrow-complex-key-example

A working Rust example for how to implement Borrow for complex keys

Rust

77

13 commits

updated Mar 3, 2024

See the code

README

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/

Contributors

sunshowers

12 commits

WaffleLapkin

1 commits

sunshowers-code/borrow-complex-key-example

A working Rust example for how to implement Borrow for complex keys

Rust

77

13 commits

updated Mar 3, 2024

See the code

README

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/

Contributors

sunshowers

12 commits

WaffleLapkin

1 commits

Languages

Rust

100.0%