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

Why does index_exists take an Index<'static> #367

Closed
DevQps opened this issue Jul 1, 2019 · 2 comments
Closed

Why does index_exists take an Index<'static> #367

DevQps opened this issue Jul 1, 2019 · 2 comments

Comments

@DevQps
Copy link

DevQps commented Jul 1, 2019

Description

I am trying to dynamically query if an index exists or not using the following code snippet:

let myindex = get a &str here (tried it with clone() as well)
let response = match client.index_exists(index(myindex)).send() {
    Ok(x) => x,
    Err(x) => panic!("Could not send an Index Exists request.")
};

and I get the following error:

    |         let myindex = get a &str here (tried it with clone() as well)
    |                      ^^^^^^^^^^-------------------
    |                      |
    |                      borrowed value does not live long enough
    | } <- END OF PROGRAM
    | - `myindex` dropped here while still borrowed
@KodrAus
Copy link
Member

KodrAus commented Jul 2, 2019

Hi @DevQps 👋

This is just for simplicity on the client side, but it isn't strictly necessary and I'd like to fix it up so you can use borrowed data (since we do eventually just build an owned url from it). In the meantime you can create an owned string to use:

let myindex = get a &str here (tried it with clone() as well)
let response = match client.index(myindex.to_owned()).exists().send() {
    Ok(x) => x,
    Err(x) => panic!("Could not send an Index Exists request.")
};

@KodrAus
Copy link
Member

KodrAus commented Jul 2, 2019

We've got #313 to track fixing this up so I'll close this one in favour of that issue. Please feel free to re-open though if you run into any more problems!

@KodrAus KodrAus closed this as completed Jul 2, 2019
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

2 participants