Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question: how to resolve impl Borrow<UniCase<'a>> for UniCase<&'static str> #277

Open
OliverNChalk opened this issue Jan 22, 2023 · 0 comments

Comments

@OliverNChalk
Copy link

OliverNChalk commented Jan 22, 2023

I have a minimal RustExplorer example that shows me struggling with a problem documented here in phf_shared's docs.

Key Snippet:

fn test(key: &str) {
    let map: HashMap<MyStruct, u32> = HashMap::new();
    let phf_map: phf::Map<MyStruct, u32> = phf::Map::new();

    let key = MyStruct { key };
    map.get(&key);
    phf_map.get(&key); // <- fails to compile
}

The docs mention:

Instead, this trait is implemented conservatively, without blanket impls, so that impls like this may be added. This is feasible since the set of types that implement PhfHash is intentionally small.

How might I go about solving this issue in concrete code terms?

@OliverNChalk OliverNChalk changed the title bug: unnecessarily high lifetime requirements for get(key: &T) question: how to resolve impl Borrow<UniCase<'a>> for UniCase<&'static str> Jan 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant